jQuery DataTable呈现一次仅应用于一个目标

时间:2017-12-21 08:59:05

标签: jquery datatables

我有DataTable通过ajax电话填充其数据。我正在渲染两个目标,但只渲染了第二个目标。以下是我的代码

columnDefs: [
  { responsivePriority: 1, targets: 1 },
  { responsivePriority: 2, targets: 2 },
  { responsivePriority: 3, targets: 3 },
  { responsivePriority: 7, targets: 4 },
  { responsivePriority: 4, targets: 5 },
  { responsivePriority: 5, targets: 6 },
  { responsivePriority: 6, targets: 7 },
  {
    'targets': 2,
    'render': function (data, type, full, meta) {
       return type === 'display' && data.length > 10 ?
              data.substr(0, 10) + '…' :
              data;
  },
  'targets': 7,
  'render': function (data, type, full, meta) {
    // Something here
  },
}],

此处仅targets : 7正在呈现,但不是2

1 个答案:

答案 0 :(得分:0)

关闭每个目标的},如下所示。

columnDefs: [

            { responsivePriority: 1, targets: 1 },
            { responsivePriority: 2, targets: 2 },
            { responsivePriority: 3, targets: 3 },
            { responsivePriority: 7, targets: 4 },
            { responsivePriority: 4, targets: 5 },
            { responsivePriority: 5, targets: 6 },
            { responsivePriority: 6, targets: 7 },
            { 'targets': 2,
              'render': function (data, type, full, meta) {
                 return type === 'display' && data.length > 10 ? data.substr(0,10) + '…' : data; }
           },
           { 'targets': 7,
             'render': function (data, type, full, meta) {
                //Something here
             }
           }
        ],