RowReorder + stateSave = ?

RowReorder + stateSave = ?

ajh158ajh158 Posts: 2Questions: 1Answers: 0
edited January 2022 in RowReorder

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

  • kthorngrenkthorngren Posts: 20,791Questions: 26Answers: 4,860
    Answer ✓

    The stateSave option doesn't save the table data, which the index used for rowReorder is apart of. You can use statSaveParams to custom what is saved and stateLoadParams 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

  • ajh158ajh158 Posts: 2Questions: 1Answers: 0

    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. ".

  • colincolin Posts: 15,226Questions: 1Answers: 2,593

    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

Sign In or Register to comment.