如何将数据表中 columnDefs 的目标定义为 "last"?
How can I define the targets of columnDefs in datatables as "last"?
我的目标现在设置为第 5 列:
"columnDefs": [{
"render": function (data, type, row) {
return data;
},
"targets": 5
}],
我想做的是,我不想将它定位到特定数字,而是想将它定位到最后一列。
我需要的是这样的:
"columnDefs": [{
"render": function (data, type, row) {
return data;
},
"targets": last
}],
根据 documentation,您可以为 targets
提供一个整数,它指定要使用的列的索引。
This columnDefs.targets
option provides the information required by DataTables for which columns in the table the column definition object should be applied.
It can be:
- 0 or a positive integer - column index counting from the left
- A negative integer - column index counting from the right
- A string - class name will be matched on the TH for the column (without a leading .)
- The string "_all" - all columns (i.e. assign a default)
注意第二点;您可以提供一个负整数从右开始索引,因此 -1
将是最后一列。
"columnDefs": [{
"render": function(data, type, row) {
return data;
},
"targets": -1
}],
我的目标现在设置为第 5 列:
"columnDefs": [{
"render": function (data, type, row) {
return data;
},
"targets": 5
}],
我想做的是,我不想将它定位到特定数字,而是想将它定位到最后一列。
我需要的是这样的:
"columnDefs": [{
"render": function (data, type, row) {
return data;
},
"targets": last
}],
根据 documentation,您可以为 targets
提供一个整数,它指定要使用的列的索引。
This
columnDefs.targets
option provides the information required by DataTables for which columns in the table the column definition object should be applied.It can be:
- 0 or a positive integer - column index counting from the left
- A negative integer - column index counting from the right
- A string - class name will be matched on the TH for the column (without a leading .)
- The string "_all" - all columns (i.e. assign a default)
注意第二点;您可以提供一个负整数从右开始索引,因此 -1
将是最后一列。
"columnDefs": [{
"render": function(data, type, row) {
return data;
},
"targets": -1
}],