gpt4 book ai didi

javascript - jquery-datatables 多列排序方向

转载 作者:数据小太阳 更新时间:2023-10-29 05:18:51 24 4
gpt4 key购买 nike

使用 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 ------------------ --

期望结果的图片enter image description here

最佳答案

使用

$(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/

24 4 0
文章推荐: javascript - Angular : use a variable into
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com