首页 > 解决方案 > 对数据表行组进行排序

问题描述

我正在使用 jQuery DataTables 插件。我想按 column1 创建一个 Datatables 行组,并按 column2 对单个组进行排序。但是,当我对 column2 进行排序时,行组不起作用

var table = $('#DT_StatMov').DataTable({
  "ajax": {
    "url": url,
    "type": "POST",
    "datatype": "json"
  },
  "columns": [{
    "data": "Name"
  }, {
    "data": "Product"
  }, {
    "data": "Date",
    "render": function(data) {
      return moment(data).format('D/M/Y');
    }
  }],
  "orderFixed": [1, 'asc'],
  "order": [2, 'desc'],
  rowGroup: {
    startRender: null,
    endRender: function(rows, group) {
      return group + ' (' + rows.count() + ')';
    },
    dataSrc: 'Product'
  },
  "scrollCollapse": true,
  "search": {
    "caseInsensitive": true,
  },
  "ordering": false,
  "processing": true

});

标签: javascriptjquerydatatabledatatables

解决方案


推荐阅读