php - Datatables sorting -


i have problem sorting data using jquery plugin data tables. form table database result , got default sorting, sort first column descending:

<table cellpadding="0" cellspacing="0" border="0" class="display datatable tabela" id="tabela4"> <thead>     <tr>        <th>id</th>         <th>counter bw</th>         <th>counter color</th>         <th>status</th>     </tr> </thead> <tbody> <? foreach ($db_result->result() $row):?>    <tr class="gradec">       <td><?=$row->service_id;?></td>         <td><?= $row -> counter_bw; ?></td>         <td><?= $row -> counter_color; ?></td>         <td><div class="<?= $row -> service_status; ?>"><?= $row -> service_status; ?></div></td>     </tr>  <? endforeach; ?> </tbody> 

and jquery code:

$('#tabela4').datatable({ "aasorting": [[ 3, "desc" ]] }); 

problem sorting default, first column descending.

with datatables can alter sorting characteristics of table @ initialisation time. using aasorting initialisation parameter, can table how want present information. aasorting parameter array of arrays first value column sort on, , second 'asc' or 'desc' required try below:

$(document).ready(function() {     $('#example').datatable( {         "aasorting": [[ 4, "desc" ]]     } ); } ); 

for more details chek link: demo


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -