使用 jquery-datatables。
示例:http://jsfiddle.net/b2fLye17/17/
$('#example').DataTable({
filter:false,
columnDefs: [
{
targets: [1],//when sorting age column
orderData: [1,2] //sort by age then by salary
}
]
});
当您单击年龄列时,表格按年龄升序排序,然后按薪水升序排序。
我有什么选择可以让它按年龄升序排序然后按薪水降序排序?
谢谢!
------------------------ 编辑 1 ------------------ --
澄清:当年龄列按升序排序时,它应该按年龄升序排序,然后按薪水降序排序。当年龄列降序排序时,它应该按年龄降序排序,然后按薪水升序排序
------------------------ 编辑 2 ------------------ --
期望结果的图片
最佳答案
使用
$(document).ready(function() {
$('#example').DataTable({
filter:false,
columnDefs: [
{
orderData: [[1, 'asc'], [2, 'desc']]//sort by age then by salary
}
]
});
});
JS fiddle http://jsfiddle.net/b2fLye17/13/
关于javascript - jquery-datatables 多列排序方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27527160/