When I use updateSelectizeInput on the server and selectizeInput in ui, to choose multiple options from a table that I will filter by those options, Shiny shows all selections in the selection box, but I can't delete any or choose a subset of options, as it automatically updates to all options. The data comes from a reactive(), that's why I have to use updateSelectizeInput.
This is not a reprex, but represents the relationship between the variables and the codes involved:
ui <- fluidPage(navbarPage(
tabPanel("Resultados",
fluidRow(selectizeInput("muestra_selec",
"Seleccione las muestras que desea incluir en el informe:",
multiple = TRUE,
choices = NULL,
selected = NULL,
width = NULL)),
hr(),
navlistPanel("Resultados",
widths = c(2,10),
tabPanel("LCM",
mainPanel(tableOutput("lcm"))),
tabPanel("BTEX",
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Datos BTEX + Control Calidad",
DT::dataTableOutput("datos_btex_control",
width = "150%")),
tabPanel("Tabla Informe BTEX",
DT::dataTableOutput("Resultados_btex",
width = "150%")))))
)))
server <- function(input, output, session) {
output$Resultados_btex <- DT::renderDataTable({
resultados <- resultados_btex()
# Permite seleccionar datos que estan en server.
updateSelectizeInput(session,
"muestra_selec",
choices = unique(resultados$`Muestra`),
selected = unique(resultados$`Muestra`))
resultados2 <- resultados %>% dplyr::filter(resultados$`Muestra` %in% input$`muestra_selec`)
DT::datatable(data = resultados2,
extensions = c('Buttons',
'Scroller',
'AutoFill',
'RowGroup'),
options = list(pageLength = 20,
autoWidth = TRUE,
deferRender = FALSE,
scrollY = 500,
scrollX = TRUE,
scroller = TRUE,
dom = 'Bfrtip',
buttons = c('copy', 'excel','pdf'),
autoFill = TRUE,
rowGroup = list(dataSrc = 0)),
rownames = FALSE,
filter = 'top',
caption = 'Tabla de BTEX para Informe')
})
}
This is the complete list of options, when I try to remove one or more, the whole list is re-selected.