datatable Warning: Cannot reinitialise Datatable (need to disable sorting)
datatable Warning: Cannot reinitialise Datatable (need to disable sorting)
Hi, I have a datatable I'm trying to disable the sorting option from (sorting on the server side). But, we have a partial that initializes the datatable, and I can't seem to figure out how to just disable the ordering after it's already been initialize.
I tried, $('#datatable').DataTable({ "retrieve": true, "ordering": false});
but that does not work.
This discussion has been closed.
Answers
I don't believe there is a way to disable ordering after the Datatables has been initialized. To disable ordering you will need to use
orderingduring the initialization of the Datatable. Use the Single initialization technique by placing"ordering": falsein your original Datatables initialization.Kevin
We have a routine that renders the partial datatable and allows for filtering in each column. They would like that first row sorted descending (datetime field).
I'm not sure what my options are.
Use
columns.orderableto disallow the users from ordering the table. This will still allow Datatables to order the table viaorder()andorder. Set the initial table order you want toorderand setcolumns.orderablefalse for all columns usingoption columnDefswithcolumnDefs.targetsset to_all.Kevin
ok, I've set the order by on the server side. I don't require datatables to sort asc on the first column. I need to get sorting to work with our filtering routine.
Set the
orderoption to what you want the initial table order to be. See the examples in the docs for ideas.Sorry, I'm not clear what this means. If you want to set the table order based on what filters are chosen you can use
order()to change the table order. If this doens't help please provide more details.Kevin