如何仅对某些列进行排序
How to sort only certain columns
我正在使用 jQuery DataTables 插件对 table 数据进行排序。我有四列:姓名、职位、办公室和年龄。我想要的是用户只能对 Name 和 Age 列进行排序,而不是所有列。但我无法停止对其他列进行排序。你能推荐点什么吗?
此代码禁用排序,0 - 列索引。
对于旧版本
aoColumnDefs: [
{
bSortable: false,
aTargets: [ 0 ]
}
]
对于数据表 1.10+
columnDefs: [
{ orderable: false, targets: 0 }
]
特别是例如,你需要这个
$(document).ready(function() {
$('#example').dataTable( {
"order": [[ 0, "desc" ]],
"aoColumns": [
null,
{ "bSortable": false },
{ "bSortable": false },
null
]
} );
} );
我正在使用 jQuery DataTables 插件对 table 数据进行排序。我有四列:姓名、职位、办公室和年龄。我想要的是用户只能对 Name 和 Age 列进行排序,而不是所有列。但我无法停止对其他列进行排序。你能推荐点什么吗?
此代码禁用排序,0 - 列索引。 对于旧版本
aoColumnDefs: [
{
bSortable: false,
aTargets: [ 0 ]
}
]
对于数据表 1.10+
columnDefs: [
{ orderable: false, targets: 0 }
]
特别是例如,你需要这个
$(document).ready(function() {
$('#example').dataTable( {
"order": [[ 0, "desc" ]],
"aoColumns": [
null,
{ "bSortable": false },
{ "bSortable": false },
null
]
} );
} );