数据表 1.10.18
我已经按如下方式定义了我的表的列:
columns: [
{ "data": "expand_link", "name": "expand_link" },
{ "data": "date", "name": "date" },
{ "data": "col1", "name": "col1" },
{ "data": "col2", "name": "col2" },
{ "data": "col3", "name": "col3" },
],
"columnDefs": [
{"width": "5%", "targets": 0},
{"width": "12%", "targets": 1},
{"width": "35%", "targets": 2},
{"width": "35%", "targets": 3},
{"width": "12%", "targets": 4},
{"orderable": false, "targets": [0, 2, 3, 4]} // Can order by Date only
],
{"orderable": false, "targets": [0, 2, 3, 4]}
意味着不可能对第 0、2、3 和 4 列进行排序. 这意味着第 1 列是可订购的。
但是当呈现表格时,它会将向上/向下箭头图标放在第 0 列和第 1 列上:
其他列(col1...col3
,索引 2 - 4)没问题,因为它们不包含预期的排序图标:
为什么它在 js 中指定后对第 0 列 (expand_link
) 不起作用?
最佳答案
https://datatables.net/reference/option/columns.orderable#Comments 有用户评论说到这里,
Note that in both examples given, a (disabled) sort control will still appear on column 0 unless you specify a default order on a different column using order.
After some more research, it looks like this is actually intended behavior because the table is by default sorted on the first column. So the indicator is there to show you that the table is sorted on that column. In order to remove the indicator, you need to tell the table to default sort on a different column, or no column at all.
关于jquery - DataTables 将排序图标放在指定为没有的列上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57902737/