shinyWidgets
shinyWidgets copied to clipboard
Select a whole group in pickerInput
First of all, thank you for your wonderful package ! I am currently using the pickerInput, with grouped choices (in a list). I am looking for a way to select/unselect a whole groupe in one click (ex. by clicking on the name of the group or something else...)
In the following example I would like to quickly select all the "listA" choices.
library("shiny")
library("shinyWidgets")
ui <- fluidPage(
br(),
pickerInput(
inputId = "p1",
label = "Default",
multiple = TRUE,
choices = list("listA"=rownames(mtcars)[1:16], "listB"=rownames(mtcars)[17:32]),
selected = rownames(mtcars)
)
)
server <- function(input, output, session) {}
shinyApp(ui = ui, server = server)
Thank you Elise
Hi, You're welcome :) That's an interesting fonctionnality ! However I don't know if it's possible... I'll look into it and let you know.
Victor
Did this ever get looked in to further? I've found that it's a piece of functionality that is quite often asked about.
This functionnality is available in virtualSelectInput() (added in shinyWidgets v0.7.0):
library(shiny)
library(shinyWidgets)
ui <- fluidPage(
fluidRow(
column(
width = 4,
virtualSelectInput(
inputId = "my_id",
label = "Select groups :",
choices = list(`East Coast` = list("NY", "NJ", "CT"),
`West Coast` = list("WA", "OR", "CA"),
`Midwest` = list("MN", "WI", "IA")),
multiple = TRUE
)
),
column(
width = 4,
verbatimTextOutput("res")
)
)
)
server <- function(input, output, session) {
output$res <- renderPrint(input$my_id)
}
shinyApp(ui, server)
But I don't think pickerInput will ever support it.
Victor
Thanks for the quick answer! That's a shame, but it makes sense not to focus on that feature in pickerInput if it exists and works well in virtualSelectInput.
I din't know virtualSelectInput but it does exactly what I wanted. Thanks !