Hello.
I'm trying to write an application in which the user can select an arbitrary set of rows in a DataTable by clicking on a row or a checkbox in the row to toggle the row selection state. The table is long and pageable.
In my initial attempts I stored the visual selection indicator in the DataTable and sent it to R using Shiny.onInputChange. This didn't work because of the server-side DataTable processing; as the user paged the table R knew what was selected but the visual selection indicators got lost since Shiny didn't know about them.
My second attempt stores the selection indicator in a column in the table and re-renders the table whenever there's a change in the selection state. Unfortunately this doesn't work either, because while the state indicator does get displayed properly there is other user state in the DataTable (page number, number of rows per page, filter values, search value) which gets lost when the table is re-rendered.
DataTables has a stateSave option which looked like it might fix this but unfortunately setting it didn't help. I suspect this has something to do with how the Shiny server-side processing works.
There are also stateSaveCallback and stateLoadCallback options, but my attempts to use the first just hang up the browser and I'm not even sure what I would do with the second.
I might be able to work around the problem by making the table non-pageable and moving the filter boxes to the top (I haven't tried this but presumably it's possible) but it's not ideal.
Does anyone have a solution to the big problem, which is keeping row-selection synchronized between R and the visual selection indicator in a pageable DataTable without disturbing the DataTable?
Or a way to save/restore the DataTable state?
Or maybe just a better way to do row selection?
Thanks,
Ron