I have a Shiny app in ShinyProxy which requires user login to access. I have a DT::datatable in the app which allows the user to re-order the columns (there are about 20-30 columns of data, so it’s a pain to re-order them). If they re-order the columns first, then use any filters/slicers, the columns are re-ordered back to the default; if they leave the app and re-open it, the columns are back to the default order.
I’d like to give the user a “save column order” ActionButton and then store those settings per user in a Redis so that when they use filters and/or leave and re-enter the app, they have their preferred column order instead of the default that I’ve set up – want to make it easy on them!!
I’ve found this site (https://rstudio.github.io/DT/shiny.html) which gets me close, but no cigar. I was thinking it may be something like input$tableId_columns_all
or input$tableId_columns
– however, those didn’t work/returned NA.
I’ve tried significant googling and most things I find that seem like they’d get me my answer are either Python or jQuery, which I don’t believe would solve my problem.
I’m open to suggestions which follow the ActionButton + redis method I’ve thought of or completely different idea, too! I’m really just looking to save user settings in ShinyProxy.
Thank you!!
3
Answers
I don’t know how you can save/restore the order but here is how you can get the order:
I come really late with my solution but this could be of interest for some of you. Here, we get the final names of the column header.
Using
stateSave = TRUE
in thedatable
options
might be a solution, too. Check this post.