datatable Warning: Cannot reinitialise Datatable (need to disable sorting)
datatable Warning: Cannot reinitialise Datatable (need to disable sorting)
merlin2049er
Posts: 6Questions: 2Answers: 0
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.
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
ordering
during the initialization of the Datatable. Use the Single initialization technique by placing"ordering": false
in 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.orderable
to 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 toorder
and setcolumns.orderable
false for all columns usingoption columnDefs
withcolumnDefs.targets
set 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
order
option 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