Sort numbers high-to-low on the first click
Sort numbers high-to-low on the first click
By default, when you sort a table via a column with numbers, the first click makes the table sort low-to-high, and the next click makes it go high-to-low.
How can I make the sortorder go from high to low in a certain column after the first click on its <th>
?
(Story behind the question is that we are mighty proud of the rows with high numbers, so we want them to appear first.
And I am sure that this question has been asked and answered here before, but I must have been using the wrong search terms. Thanks for any help!)
This question has an accepted answers - jump to answer
Answers
You can use
order
to set the initial order of that column. Another option is to usecolumns.orderSequence
to define the order behavior you want.Kevin
Thanks! Got it to work after a couple of minutes when I realised that Datatables apparently starts counting columns at
0
- the example in the docs starting at1
put me on the wrong foot.