Set Sorting Priority on Button Click
Set Sorting Priority on Button Click

Hi All,
I'm trying to adjust the sort priority when the buttons are clicked in the below example. When "Time" is clicked, the sort would go by fastest "Prologue" time - and then when "Points" is clicked, the sort order would return to sorting by total points.
I tried adding the "order" attribute (the two "new line of codes") on the button call, without any luck.
http://live.datatables.net/yohuluco/5/edit
buttons: [
{
extend: 'colvisGroup',
text: 'Points',
show: [ 4, 6, 8, 10, 12 ],
hide: [ 5, 7, 9, 11 ],
order: [[ 4, 'desc' ]] // new line of code
},
{
extend: 'colvisGroup',
text: 'Times',
show: [ 5, 7, 9, 11 ],
hide: [ 4, 6, 8, 10, 12 ],
order: [[ 5, 'desc' ]] // new line of code
}
],
Thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The easiest way would be to call
order()
within thebuttons-action
function - you've got theif
statements there so just need to slot in the ordering you want for each case,Colin
Thanks Colin.