I try to bookmark selectizeGroup (from shinyWidgets) filters. I used onBookmark and onRestore, however it does not seem to store the filters set by the user.
Here is a sample code for this problem:
library(shiny)
library(shinyWidgets)
data("mpg", package = "ggplot2")
ui <- function(request) {
fluidPage(fluidRow(
column(
width = 10,
offset = 1,
bookmarkButton(),
tags$h3("Filter data with selectize group"),
panel(selectizeGroupUI(
id = "my-filters",
params = list(
manufacturer = list(inputId = "manufacturer", title = "Manufacturer:"),
model = list(inputId = "model", title = "Model:"),
trans = list(inputId = "trans", title = "Trans:"),
class = list(inputId = "class", title = "Class:")
)
), status = "primary"),
DT::dataTableOutput(outputId = "table"))))}
server <- function(input, output, session) {
vals <- reactiveValues()
vals$sum <- NULL
res_mod <- callModule(
module = selectizeGroupServer,
id = "my-filters",
data = mpg,
vars = c("manufacturer", "model", "trans", "class"))
output$table <- DT::renderDataTable(res_mod())
# Bookmarking code --------------------------
onBookmark(function(state)
state$values$filtered <- res_mod()})
onRestore(function(state){
vals$sum <- state$values$filtered})
}
shinyApp(ui, server, enableBookmarking = "server")
Any ideas on how I can bookmark all the filters set in selectizeGroup?