0

我正在为 Jquery 使用数据表插件。我想按降序显示记录并且它工作正常。但是当用户单击标题复选框时,我不想再次对其进行排序,因为它会刷新并取消选中所有复选框。这是我的代码

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;
});

怎么{ "bSortable": false }aaSorting

4

1 回答 1

0

要禁用表中特定行的排序,只需将类添加no-sort<th>表定义中,然后将此代码添加到数据表初始化中:

$('.dataTable').dataTable({

    // Disable sorting on the no-sort class
    "aoColumnDefs" : [ {
        "bSortable" : false,
        "aTargets" : [ "no-sort" ]
    } ]
});
于 2013-06-17T22:22:51.090 回答