jQuery datatables columnDefs 以名称而不是索引为目标
jQuery datatables columnDefs target a name rather than index
在此代码中:
$('#example').dataTable( {
"columnDefs": [ {
"targets": 0,
"searchable": false
} ]
} );
targets 已被赋予一个列索引。但就我而言,列可以有不同的顺序。所以我的问题是,可以给 "targets" 列参数的名称吗?如果可以,怎么给?
来自 documentation(强调我的):
This targets
property tells DataTables which column(s) the
definition should be applied to. 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
- The string "_all" - all columns (i.e. assign a default)
在此代码中:
$('#example').dataTable( {
"columnDefs": [ {
"targets": 0,
"searchable": false
} ]
} );
targets 已被赋予一个列索引。但就我而言,列可以有不同的顺序。所以我的问题是,可以给 "targets" 列参数的名称吗?如果可以,怎么给?
来自 documentation(强调我的):
This
targets
property tells DataTables which column(s) the definition should be applied to. 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
- The string "_all" - all columns (i.e. assign a default)