Feature request: enhance orderSequence option to allow going back to unsorted state
Feature request: enhance orderSequence option to allow going back to unsorted state
Tablefak
Posts: 35Questions: 8Answers: 0
I was surprised to find out this isn't implemented, and nobody seems to even have asked for this before
Currently, the only acceptable values for the orderSequence option are "asc" and "desc". Which means that if the user decided to sort some column, there's no way to go back to the unsorted state. In my opinion, it would make a lot of sense to have a third value like "none" which would do this.
This question has an accepted answers - jump to answer
Answers
You can get the rows in the unsorted state by using order: index
Not sure whether you can use it as a command to reorder the table. I am using this to export data to Excel in the unsorted state.
https://datatables.net/reference/type/selector-modifier
And this is from my own coding (exportOptions from the Excel export mentioned above). Works fine.
UPDATE:
Just checked it:
I guess all you need to do is to pass an empty array like this:
That should redraw the table in index order as well.
Hi. Thank you for looking into it.
From what I understood, I need to do the following:
1. Hook into the "order" event.
2. When it fires, determine if my column was in the last order state (e.g. "desc", if my sequence is
["asc", "desc"]
).3. Run
.order([]).draw()
for that specific column.This looks like a lot of hacking to me. It wouldn't be very easy for me to implement that correctly. That's why I wish there was a native way to achieve this.
I still haven't understood your use case. Can you describe what you need to achieve? Just in plain English please.
What your looking for is actually coming in DataTables 2 and has already been committed. I don't know yet when 2 will be released - there is still a bunch of stuff to do for it, but it is coming. CloudTables uses the development version of DT2 and you can see (that I think is) the behaviour you are looking for on the demo table. Click a header to sort multiple times - the third state is to revert to the unsorted state.
Allan