Закажите DataTable
$(document).ready(function() {
$('#example').DataTable( {
"order": [[ 3, "desc" ]]
} );
} );
$(document).ready(function() {
$('#example').DataTable( {
"order": [[ 3, "desc" ]]
} );
} );
var table = $('#example').DataTable();
var order = table.order();
alert( 'Table is ordered by column: ' + order[0][0] + ', direction:' + order[0][1]);
var title = table.column(order[0][0]).header();
alert( 'Ordering column title: ' + $(title).html() );
var table = $('#table').DataTable({
data: data,
columns: [
{data: 'id', title: '#'}, //must have
],
columnDefs: [{
sortable: false,
class: "index",
targets: 0
}],
order: [[ 0, 'asc' ]],
})
table.on( 'order.dt search.dt', function () {
table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
cell.innerHTML = i+1;
});
}).draw();