简体   繁体   中英

pickerInput default select all choices

I have about a dozen pickerInputs, and each time I run my shiny app, everything is set to nothing selected. I have to manually select everything before the output works which is a little annoying. Is there a way for pickerInput to default to "select all" each time the app runs?

You can use the selected argument of pickerInput . Just pass all your choices to selected , which will choose everything when the app initializes. Setting action-box option to True will also build Select All & Deselect All buttons by default, which would improve your current workflow. Here is a minimal example:

library(shiny)
library(shinyWidgets)

ui <- fluidPage(
  pickerInput(
    inputId = "my_input",
    label = "TEST",
    choices = 1:10,    # provide choices - integers from 1 to 10
    selected = 1:10,   # select - integers from 1 to 10 
    options = list(`actions-box` = TRUE),   # build buttons for collective selection
    multiple = T
  )
)

server <- function(input, output) {}

shinyApp(ui = ui, server = server)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM