Using jquery-datatables.
Example: 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
}
]
});
When you click the age column, The table sort by age ascending then by salary ascending.
What would be my options to make it sort by age ascending then by salary descending ?
Thanks !
-------------------------- Edit 1 ---------------------
Clarification : When the age column is sorted ascending it should sort by age ascending then by salary descending. When the age column is sorted descending it should sort by age descending then by salary ascending
-------------------------- Edit 2 ---------------------
A picture of the desired result
Use
$(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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With