RowReorder + stateSave = ?
RowReorder + stateSave = ?
I'd like to
1) use the RowReorder extension to enable a user to reorder a data set
2) have the user-defined order persist across page loads using stateSave
In order to try this out, I saved the RowReorder "DataTables Scrolling" example locally and edited it to add stateSave: true to the configuration.
When I drag rows around and then reload the page, the order is reset to the default.
Am I doing something wrong?
Thanks!
Tony
This question has an accepted answers - jump to answer
Answers
The
stateSave
option doesn't save the table data, which the index used for rowReorder is apart of. You can usestatSaveParams
to custom what is saved andstateLoadParams
to apply the customized saved data. You will need to determine how to map the rowReorder index to the correct rows.A better option might be to start that information the database with the row data. You can use the
ow-reorder
event to save the changes via ajax or the Editor if using the Editor library.Kevin
Thanks Kevin. Your comment mostly makes sense, but I don't understand what you mean when you say "A better option might be to start that information the database with the row data. ".
Kevin meant to say it's better to store the updated row order in the database itself, rather than using
stateSave
and then reshuffling on the client - something like this with Editor.Colin