Dynamic sorting problem with column sorting icons
Dynamic sorting problem with column sorting icons
Hi, I have a datatable that is sorted dynamically based on which columns are pulled through from db. I basically have a list of links through to a datatable and depending which link is clicked, the ordering will be different. As such I cannot set a default order on the datatable because there is no default order, however, if I set it to have no default then the first render always shows the first column icon as being sorted; is there a way to stop this happening? thanks
This question has an accepted answers - jump to answer
Answers
Yes - use
order
and set it to be an empty array to have no default order.Allan
Hi Allan, thanks for the quick reply! however, I am doing sorting on each link through, its just not the same every time. My data is dynamically ordered in the c# controller code that I call to populate the table. (im using MVC). If I set order: [] then I get "No data available in table" on screen. Is there a way to populate order: ["my ordering from controller"] on the first render? I am doing an ajax post to get the data. I had tried passing a string[][] in to the model and then placing that in the order: but I think there is probably an issue with the indexing as I am actually passing ["1","asc"] with a string [][] not [1,"asc"] and I just see a blank page. Thanks!
The
order
option should have no effect what data is in the table, but the ordering of the data. You noted that you didn't want a default order - settingorder
to be an empty array is how to do that (i.e. data is shown in the order that it has been read in).Not really. You could pass back the ordering information and use
initComplete
withorder()
to set the ordering of the table. Calldraw()
and the next draw will use the order set.Allan