-2

I have taken a sample code of one of the Shiny Flexdashboard. In the sample code there is a drop down menu to select one region at a time. I just want to know is there a way to select all the values in the drop down menu?

Kindly find the code in below link,

beta.rstudioconnect.com/jjallaire/shiny-embedding

for code, click "Source Code" on the top extreme right.

Regards,

Mohan

Mohan Raj
  • 77
  • 1
  • 2
  • 9

1 Answers1

1

You can do

library(shiny)
ui = fluidPage(
  selectInput("sel", NULL, letters[1:2], multiple = T),
  actionButton("but", "all")
)
server <- function(input, output, session) {
  observeEvent(input$but, {
    updateSelectInput(session, "sel", selected = letters[1:2])
  })
}
shinyApp(ui, server)

Use ?updateSelectInput to access the documentation on that function.

lukeA
  • 53,097
  • 5
  • 97
  • 100
  • Thanks Luke for your input. Ya I have tried it. It worked fine. But, what i require is that if i have 100 values in the drill down, then how can i select all the values at once. In case of your example then i need to manually select all the 100 values one by one. Let me know if you have understood my problem. – Mohan Raj Jun 19 '17 at 13:42
  • @MohanRaj Use a button to be able to select all? – lukeA Jun 19 '17 at 14:19
  • Ya Luke I don't know as how i can do that. In case if you have any sample code or reference has if it is done in anywhere it will be very helpful – Mohan Raj Jun 20 '17 at 08:38