How to keep the order in select filter the same as table?
How to keep the order in select filter the same as table?
Hello,
I have been using datatables for a while now,
Lately, I implemented the select filter function (Select2 with multiple select) to filter the result on the table,
I generate the result on a table using JSON, the data is already sorted (No sorting on the table),
When using the filter, the result on the filter is not in the same order as the table,
Example on the table:
Floor 1
Floor 2
Floor 3
....
Floor 10
Floor 11
On the select:
Floor 1
Floor 10
Floor 11
....
Is there a simple way to make the result on the filter in the same sort as of the table?
By the way, I have multiple filters, and the results are dynamic (Number, Characters...), I would like a general solution to correct this.
Thank you.
This question has an accepted answers - jump to answer
Answers
This is the JS code I use for the filter:
Try removing
.sort()
from line 18 of your above code snippet.Kevin
@kthorngren Thank you for the answer, it's working perfectly.