如何仅对某些列进行排序 [英] How to sort only certain columns
本文介绍了如何仅对某些列进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 jQuery DataTables 插件对表数据进行排序.我有四列:姓名,职位,职务和年龄.我想要的是用户只能对名称"和年龄"列进行排序,而不对所有列进行排序.但是我无法停止在其他列上进行排序.你能建议点什么吗?
I am using jQuery DataTables plugin to sort table data. I have four columns: Name, Position, Office and Age. What I want is user to be able to sort only Name and Age columns, not all the columns. But I am not able to stop sorting on OTHER columns. Can you please suggest something?
推荐答案
此代码禁用排序-0-列索引. 对于旧版本
This code disable sorting, 0 - index of column. For old version
aoColumnDefs: [
{
bSortable: false,
aTargets: [ 0 ]
}
]
对于DataTables 1.10 +
for DataTables 1.10+
columnDefs: [
{ orderable: false, targets: 0 }
]
例如,您特别需要这个
$(document).ready(function() {
$('#example').dataTable( {
"order": [[ 0, "desc" ]],
"aoColumns": [
null,
{ "bSortable": false },
{ "bSortable": false },
null
]
} );
} );
这篇关于如何仅对某些列进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文