Is there a way to set default sorting to include multiple columns?
Is there a way to set default sorting to include multiple columns?
I have a table that displays some regulatory languages, and their numbering scheme is in decimal format (ie. 1.0, 1.11, 2.3, etc). The easiest way that I've found for the users to be able to sort this data is to have 3 separate columns:
one for the first number (before the decimal point): this data is a Long type, and the column is hidden,
one for the second number (after the decimal point): this data is a Long type, and the column is hidden,
one for both columns combined: this data is a String, and is created by simply taking the first number + "." + second number. This is the column that the users see.
On that visible column, I set the aoColumnDefs to target it, then set the orderData parameter to target the first number, then the second number. When the user clicks to sort the visible column, it sorts perfectly.
Unfortunately, I haven't been able to figure out a way to have that sort order default when the table is created. I see that you can set an "order" parameter on the table, but I can't find any examples of multiple columns set for that parameter. Any ideas?
Answers
Nevermind!
Looks like all I had to do was set the
"order": [[ ]]
value to look at that visible column that I had set the sort values on. Datatables then sees that I set the sort values to look at the other two columns and that is how it sorts.
I am glad you figured it out.
Without a visual example of your problem, it is difficult to understand what you mean.