Can you order DataTables by calling some function?
Can you order DataTables by calling some function?
Hello all,
I would like to ask whether DataTables' has a function that I can call that would order the table based on the call? For example, I added a button on my site that would say "Order DataTables by Popularity". Click on the button would call the function I'm missing: DataTablesOrderBy("column 1").
Of course, DataTables already have headers that can be clicked in order to order the table, but I would like to be able to do the ordering using elements that are outside my DataTables instance.
This question has an accepted answers - jump to answer
Answers
https://datatables.net/reference/api/order()
Add this to your event handler. Please note that the first argument is the index of the column in the current state of the table, starting at 0. So if you are using colReorder, you will have to search for the column ID to obtain the index.
Thanks, Gordon!