While working on my shiny app I noticed that the shiny app will crash under following circumstances:
Having custom collection buttons with the DT Buttons Extension.
Using the Extensions FixedColumns, FixedHeader and setting ScrollX and ScrollY.
The buttons will alter between the two tables. When using/pressing them multiple times (around 10-15 times on my machine) shiny will get slower and slower and eventually will crash/not respond.
But only when using all 3 things at the same time, shiny will crash when using the buttons multiple times.
So the "fix" I found was either set
fixedColumns = NULL
or
fixedHeader = FALSE
or
scrollX = FALSE, scrollY = ""
.
But I want to use all 3 at the same time.
I really don't know how and why his happen and why a combination of only two works fine, but all 3 are too much.
Has someone an idea how to avoid the crash behavior while using all 3 things?
Exemple Code:
server = function(input, output){
buttons = list(list(extend="collection",text="A",
action=DT::JS("function ( e, dt, node, config ) {Shiny.setInputValue('A', true, {priority: 'event'});}")),
list(extend="collection",text="B",
action=DT::JS("function ( e, dt, node, config ) {Shiny.setInputValue('B', true, {priority: 'event'});}")) )
table.a = DT::renderDataTable(DT::datatable(iris,
extensions = c("FixedColumns","FixedHeader","Buttons"),
options=list(dom = "<t>B",buttons = buttons,
fixedColumns = list(leftColumns = 0),
fixedHeader = TRUE,
scrollX = TRUE,
scrollY = "200px")))
table.b = DT::renderDataTable(DT::datatable(mtcars,
extensions = c("FixedColumns","FixedHeader","Buttons"),
options=list(dom = "<t>B",buttons = buttons,
fixedColumns = list(leftColumns = 0),
fixedHeader = TRUE,
scrollX = TRUE,
scrollY = "200px")))
output$table = table.a
shiny::observeEvent(input$A, {output$table = table.a})
shiny::observeEvent(input$B, {output$table = table.b})
}
shiny::shinyApp(shiny::mainPanel(DT::dataTableOutput("table")),server)