-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datatable in insertUI rerenders other datatable #369
Comments
Sorry I don't have time to investigate this issue for now. I wonder if @bborgesr has any ideas here. |
Thanks for the report. It seems like for In your case, what is happening is that library(shiny)
library(DT)
numUI <- 0
ui <- shinyUI(fluidPage(
mainPanel(
sliderInput("number","Number of tables",1,10,1,1),
tags$div(id="tables")
)))
server <- shinyServer(function(input, output, session) {
observe({
if (input$number > numUI) {
for (num in (numUI+1):input$number) {
insertUI("#tables", "beforeBegin", DT::dataTableOutput(paste0("table", num)))
output[[paste0("table",num)]] <- DT::renderDataTable(head(mtcars), server = FALSE)
}
}
if (input$number < numUI) {
for (num in (input$number+1):numUI) {
removeUI(paste0("#table", num))
}
}
numUI <<- input$number
})
})
# Run the application
shinyApp(ui = ui, server = server) PS: @yihui, you can close the issue here, since it's a Shiny issue, not a DT issue. |
Excellent. Thanks a lot, Barbara! |
See this SO question: http://stackoverflow.com/questions/40225191/generating-dynamic-number-of-datatables-without-rerendering/
Reproducible example from @warmoverflow
When you insert a new datatable all of the datatables rerender, so information like selected rows, and the search filters are lost. This seems counter to the whole purpose of
insertUI
as an alternative torenderUI
.Thanks
The text was updated successfully, but these errors were encountered: