I am using datatables plugin for Jquery.I want to display records in descending order and it works fine.But when user clicks on header check box,I do not want to sort it again as it refreshes and unchecks all checkboxes.Here is my code
var oTable = $('#listings_row').dataTable( {
"aaSorting": [[ 0, "desc" ]],
"aoColumns": [ null, null],
"sDom": 'R<>rt<ilp><"clear">',
"iDisplayLength": 25,
"iDisplayStart": 0,
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sAjaxSource": "test.php",
"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
var id = aData[0];
$(nRow).attr("id",id);
// Bold the grade for all 'A' grade browsers
if ( aData[0] != 0 )
{
$('td:eq(0)', nRow).html( '<input type="checkbox" name="delid[]" value="'+ aData[0] +'" />' );
} return nRow;
});
How to use { "bSortable": false }
with aaSorting
?
To disable sorting in a specific row on a table, just add the class no-sort
to your <th>
table definitions and add this code to the datatable initialization:
$('.dataTable').dataTable({
// Disable sorting on the no-sort class
"aoColumnDefs" : [ {
"bSortable" : false,
"aTargets" : [ "no-sort" ]
} ]
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.