我有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
。
答案 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
}
}
],