Initial Sort Order using Serverside and Ordering = false
Initial Sort Order using Serverside and Ordering = false
UPEngineer
Posts: 93Questions: 0Answers: 1
This may be a stupid question, but I have a datatable where ordering is set to false, and I am using server side processing with the SSP class. The problem is I can't set the initial sort order. I have tried every datatables method I can think of to no avail.
For example, columns 1 and 2 contain last name and first name respectively. I want the table to display in ascending order on both columns when it loads.
Any suggestions?
This discussion has been closed.
Replies
and
These two statements seem to contradict each other. You can't disable ordering and then expect ordering to work.
What you can do is use
columns.orderable
to disable the end user's ability to order data by clicking on columns. That will still allow the table to be ordered via the init options or the API, but not the end user.Allan
Maybe I didn't make it clear what I need.
I have a table that I do not want the end user to be able to sort. It is a listing of names, and when it displays, I want it to display in alphabetical order.
I did have
columns.orderable
set to false and I also hadcolumns.orderData
set for the two columns for the initial display.This is what I have :
"columnDefs": [
{
"targets": [ '_all' ],
"orderable": false
},
{
"targets": [ 1 ],
"orderData": [ 1, 2 ]
},
It works great, but the sort icons still display on those two columns. They don't do anything, but I don't want to confuse the end user.
In the
columns.orderable
documentation, there is a comment about this as well. May just be some simple glitch or something.You'd need to remove or override the sort icons from the CSS if you don't want them.
Allan
Thanks Allan. That's what I ended up doing.