Datatable sorting group rows
Datatable sorting group rows
I have a table with columns : Office, Age, Start date, Salary.
I have created a Datatable by adding a grouping row per Office with as additional information the sum of the ages of the group. (I wrote my example here : http://live.datatables.net/wuwaxiqe/235/edit)
What I would like to do is when the user clicks on "Age":
1) Order each element of the group by age -> Done. this is easy by adding the parameter "orderFixed":[[groupColumn, 'asc']].
2) Order the groups themselves by total age. In other words here on my example we would have first San francisco (total 632) then London (469) etc ....
I have difficulties on this second point. Thanks !
Answers
I can't think of an easy way of doing that second requirement. The problem, as I'm sure you're aware, is that the ordering is over the table, not per page.
The only possible way of doing it would be to:
1. in
drawCallback
remove all the rows from the table (not using the DataTables API, but similar to how you're adding the headers)2. work out the ordering yourself for the headers
3. put those records back into the table again (similar to how you're doing the headers now)
It shouldn't be too complex, but I'm not sure if there'll be any knock-on effects from it,
Colin
Thanks for your answer