Default sorting
Default sorting
I understand that you can alter the Default ordering by adding:
$('#example').DataTable({
order:[[3, 'desc'], [0, 'asc']]
});
But is there a way to alter to original order so that if a user selects a header it always sorts in descending order rather than in ascending order as happens now.
I have a lot of columns that are numeric which hold a lot of empty or zero values and the users have to click the header twice: once to sort in the default ascending order and the second time to sort in the descending order.
Ideally the first column would sort ascending as it is alphabetical, but all other columns should sort descending as they are numerical.
Milton.
Answers
See if
columns.orderSequence
does what you want.Kevin
Thanks again Kevin,
I added the order sequence as suggested into the columnDefs, but I am not getting the correct sort order.
I assume it is because My required order when the user first views the Table is set in "order" and then "order sequence" is after this?
I tried moving the ColumnDefs above the "order" line but was getting a syntax error.
Milton.
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin