How to replace colunm sort behaviour with my own
How to replace colunm sort behaviour with my own
yassen
Posts: 10Questions: 0Answers: 0
Hi and thanks to the authors for a great piece of software!
I try to solve the following issue:
How can I replace the default behaviour for column sorting with my own? I want to load the table from the server with that field used in an "ORDER BY" clause instead of letting the DataTables object sort the in-memory data. (Why? -- see below.)
Can anyone point me to some direction?
Your help is highly appreciated, thanks!
Yassen
P.S. Motivation:
I have a table that consists of the result of an SQL query with a LIMIT clause. When the user clicks on a column to sort the data, I need to actually perform a new query -- if I don't, the DataTables table will sort the in-memory data, but that is only a limited portion of the whole data and will not represent the true data in the database.
I try to solve the following issue:
How can I replace the default behaviour for column sorting with my own? I want to load the table from the server with that field used in an "ORDER BY" clause instead of letting the DataTables object sort the in-memory data. (Why? -- see below.)
Can anyone point me to some direction?
Your help is highly appreciated, thanks!
Yassen
P.S. Motivation:
I have a table that consists of the result of an SQL query with a LIMIT clause. When the user clicks on a column to sort the data, I need to actually perform a new query -- if I don't, the DataTables table will sort the in-memory data, but that is only a limited portion of the whole data and will not represent the true data in the database.
This discussion has been closed.
Replies
It seems that {"bSortable": false} for all columns and also adding sort listeners via fnSortListener (will the event still be fired? I'm gonna find out) should do the trick ... no?
Allan
FWIW I just took a look at some of my own code, and I'm disabling initial sort by giving aaSorting an empty array. Works for me.
Allan
I have stuff like currency (e.g. $5.34) and percent data (32.6%), which I need sorted properly (numerically, not alphabetically). Can I keep something like a hidden column only for sorting, and another one with the formatted data to show to the user? Thanks!
Allan
Another Q: How can I apply custom style (e.g. background color) for numeric data that is behind/below certain limits? (Just refer to the proper source of info so that I can educate myself.) Tanks!
Allan
Allan
When you sort the last column, the special bgr colours are lost :(
Allan, your help is *highly* appreciated, thank you!
This means that colours are only temporarily lost because DataTables code applies highlighting styles temporarily to underline the sorted column. How can one suppress that or have the DataTables code skip already coloured stuff?
Use the bSortClasses option and set it to false.
Allan
Yassen