jQuery数据表排序按钮在标题列中不可用

时间:2019-04-29 09:33:50

标签: jquery html asp.net sorting datatable

Iam根据条件使用两组表头jQuery排序仅适用于一组头

例如:如果用户选择报告类型1-将显示一组表标题,并且如果用户选择类型2-将显示另一组列标题

但是排序仅适用于一组标题

var InspectionType = $("#InspectionType").val();

if (InspectionType == 0) {
  oTable = $('#PerformanceTableView').dataTable({
    "bJQueryUI": false,
    "bServerSide": true,
    //                "bProcessing": true,
    "bDestroy": true,
    "aaSorting": [
      [0, 'desc']
    ],
    "sPaginationType": "full_numbers",
    "oLanguage": {
      "sEmptyTable": "<%: Resources.info_gen_norecordsavailable %>"
    },
    "sAjaxSource": actionUrl2,
    "fnServerParams": function(aoData) {
      aoData.push({
        "name": "DateFrom",
        "value": DateFrom
      });
      aoData.push({
        "name": "DateTo",
        "value": DateTo
      });
      aoData.push({
        "name": "RegionName",
        "value": RegionName
      });
      aoData.push({
        "name": "Name",
        "value": Name
      });
      aoData.push({
        "name": "InspectionType",
        "value": InspectionType
      });
    },
    "aoColumns": [{
        "sName": "Job No",
        "bSearchable": true,
        "bSortable": true
      },
      {
        "sName": "Vehicle No",
        "bSearchable": true,
        "bSortable": true
      },
      {
        "sName": "TO Code",
        "bSearchable": true,
        "bSortable": true
      },
      {
        "sName": "EPF NO",
        "bSearchable": true,
        "bSortable": true
      },
      {
        "sName": "Assigned Date",
        "bSearchable": true,
        "bSortable": true
      },
    ]
  });

} else {
  oTable = $('#PerformanceTableView').dataTable({
    "bJQueryUI": false,
    "bServerSide": true,
    //                "bProcessing": true,
    "bDestroy": true,
    "aaSorting": [
      [0, 'desc']
    ],
    "sPaginationType": "full_numbers",
    "oLanguage": {
      "sEmptyTable": "<%: Resources.info_gen_norecordsavailable %>"
    },
    "sAjaxSource": actionUrl2,
    "fnServerParams": function(aoData) {
      aoData.push({
        "name": "DateFrom",
        "value": DateFrom
      });
      aoData.push({
        "name": "DateTo",
        "value": DateTo
      });
      aoData.push({
        "name": "RegionName",
        "value": RegionName
      });
      aoData.push({
        "name": "Name",
        "value": Name
      });
      aoData.push({
        "name": "InspectionType",
        "value": InspectionType
      });
    },
    "aoColumns": [{
        "sName": "Job No",
        "bSearchable": true,
        "bSortable": true
      },
      {
        "sName": "Vehicle No",
        "bSearchable": true,
        "bSortable": true
      },
      {
        "sName": "TO Code",
        "bSearchable": true,
        "bSortable": true
      },
      {
        "sName": "EPF NO",
        "bSearchable": true,
        "bSortable": true
      },
      {
        "sName": "Visited Date",
        "bSearchable": true,
        "bSortable": true
      },
    ]
  });
}

1 个答案:

答案 0 :(得分:0)

  

DataTables允许同时按多个列进行排序,   可以通过多种不同方式激活:

     

用户按住Shift键单击列(添加了被单击列作为辅助列,   第三等排序列)。

     

以每列为基础(即按特定列排序,然后按   第二列(如果第一列中的数据相同),   通过columns.orderData选项。使用columns.orderData   默认情况下指定多列顺序的选项(例如[0,   1])。

     

通过order()API方法。

     

请注意,用户将点击转换为多个的能力   可以通过orderMulti选项禁用列。

     

下面的示例显示第一列具有二级顺序   应用于表格中的第二列,反之亦然   列直接绑定到第一个,而薪金列绑定到   名列。

https://datatables.net/examples/basic_init/multi_col_sort.html