Sort numbers high-to-low on the first click

Sort numbers high-to-low on the first click

EvertAlbersEvertAlbers Posts: 5Questions: 2Answers: 0

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

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    Answer ✓

    You can use order to set the initial order of that column. Another option is to use columns.orderSequence to define the order behavior you want.

    Kevin

  • EvertAlbersEvertAlbers Posts: 5Questions: 2Answers: 0

    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 at 1 put me on the wrong foot.

This discussion has been closed.