I was trying so hard to solve this problem, but it really make my mind explode.
Everything displays nicely including the paging,listing and the date are sorted by asc (Default)
After I added in Java script(make it sort by desc) This is javascript:
<script type='text/javascript' src='../js/jquery.js'></script>
<script type='text/javascript'>
jQuery(document).ready(function(j)
{
$('#example').dataTable({
'aaSorting': [[0,'desc']] //Sorts 1st column asc
})
});
</script>
Data listing sorted, everything is still cool, but the paging buttons are missing, left "Showing X to X of X entries"
Please Help!
Here is my script added this at the bottom of the script import datatable js
<script type='text/javascript' src='assets/plugins/datatables/jquery.dataTables.min.js'></script>
<script type='text/javascript' src='assets/plugins/datatables/dataTables.bootstrap.js'></script>
<script type='text/javascript' src='assets/demo/demo-datatables.js'></script>
Table script:
<table cellpadding="0" cellspacing="0" border="0" class="stdtable stdtablecb datatables" id="example">
<thead>
<tr>
<th>'.__("Date").'</th>
<th>'.__("Description").'</th>
<th>'.__("Credit").'</th>
<th>'.__("Debit").'</th>
<th>'.__("Balance").'</th>
</tr>
</thead>
<tbody>
'.$his_row.'
</tbody>
</table>
////////////////////////////
for($i=0;$i<$this_page_total;$i++){
$p=mysql_fetch_assoc($r);
$his_row.='
<tr class="'.($k==0?'even':'odd').'">
<td class="center">'.$p["cdate"].'</td>
<td>'.$p["descr"].'</td>
<td>'.number_format(in_array($p['type'],array('c','credit'))? $p['amount'] : 0, 2).'</td>
<td>'.number_format(!in_array($p['type'],array('c','credit'))? $p['amount'] : 0, 2).'</td>
<td class="center">'.nl2br($p["bal"]).'</td>
</tr>
';
$k=1-$k;
}
Here are the link for my datatables (Sorry for I cant post any image here due to low reputation) This is the datatable that sort by default(ASC) https://www.dropbox.com/s/fj8lqj766o4vgeb/Screenshot%202015-03-27%2018.33.52.png?dl=0
This is the datatable that after insert javascript sort by desc https://www.dropbox.com/s/pphc70cp7ntyty8/Screenshot%202015-03-27%2018.34.34.png?dl=0