1
votes

Building an R Shiny app with DataTable functionality. I'm expecting the user to select rows in many different (dynamically generated) tables, which live on different tabs. This works well - I just need to just use SelectRows on a dataTableProxy object.

However, I often need to e.g. load a predefined selection of rows. From what I've seen, SelectRows only works if the DT object has already been rendered, i.e. after the user has clicked the tab where it exists. Is there a way to force Shiny to create all my renderDataTable objects before user manually navigating to where they exist?

PS: For simple cases there is a simple fix by using

output$mytable = DT::renderDataTable(iris, selection = list(mode = 'multiple', selected = predefined_selection))

but in this specific case it gets very messy for equally specific reasons.

PPS: My first post on stackoverflow, sorry if this is poorly formulated.

1
By "different tabs" I mean tabsetPanel(tabPanel(), ...) kind of design, no custom HTMLvients
Please post a minimal reproducible example so that it is easier for others to help you.Xiongbing Jin
Have you tried using reactiveValues with the selectRows functionality? It might workuser5029763

1 Answers

0
votes

DT has a replaceData method which redraws the table:

Implementing DT Reload within Shiny