In the shiny
application below, I want the word to be displayed inside pickerInput()
when all options of pickerInput()
are selected "all"
As an option, when you click on it, all three options will be displayed. If we can implement it with selectInput()
, then there will be no problem, but the printed output should not be affected. What should I do?
library(shiny) library(shinyWidgets) ui <- fluidPage( uiOutput("pick"), verbatimTextOutput("PR") ) server <- function(input, output, session) { output$pick<-renderUI({ pickerInput( inputId = "p9", label = "健康保险", choices = unique(as.character(iris$Species)), width = "150px", selected = unique(as.character(iris$Species)), multiple = TRUE, options = list( `actions-box` = TRUE, `deselect-all-text` = "无", `select-all-text` = "全部", `none-selected-text` = "零" ) ) }) output$PR<-renderPrint({ input$p9 }) } shinyApp(ui, server)
Here is an example based on this great answer. We use a
clickHandler
here, which changes the style ofdropdown-item
based on the click status of the containerAll
so that it is indisplay: block Switch between
anddisplay: none
. Note that on application initialization, items will only be hidden behindAll
if all selections are selected.