Reputation: 3855
I want to pass saveState argument in my shiny server.
I found following code from https://github.com/rstudio/DT/issues/76
DTApp = function(data, ..., options = list()) {
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(
fluidRow(
verbatimTextOutput('foo'),
DT::dataTableOutput('tbl')
)
),
server = function(input, output, session) {
options$ajax = list(url = dataTableAjax(session, data))
# create a widget using an Ajax URL created above
widget = datatable(data, server = TRUE, ..., options = options)
output$tbl = DT::renderDataTable(widget)
output$foo = renderPrint(str(input$tbl_state))
}
)
}
DTApp(iris, options = list(stateSave = TRUE))
As we can see here, They has pass stateSave in DTApp. However, I am building ui and server seperate. Rstudio is building app for me.
I have no idea, where to pass stateSave argument. I believe it should go into server, however, I am not sure.
Upvotes: 1
Views: 657
Reputation: 12087
stateSave
is just an option for datatable
. So change the following line
widget = datatable(data, server = TRUE, ..., options = options)
to
widget = datatable(data, server = TRUE, ..., options = list(stateSave = TRUE))
Upvotes: 1