1

I'm trying to create an action button that updates SelectInput and PickerInput ONLY when the button is clicked.

library(shiny)    

shinyUI(basicPage(

v1 <- c("a","b","c")
v2 <- 1:3
data <- data.frame(v1,v2)

pickerInput("v1",label = "v1",""),
uiOutput("secondSelection"),
actionButton("go", "Update")

))


shinyServer(function(input, output) {

output$secondSelection <- renderUI({
pickerInput("v2", "Variable 2:","")
})

v1vals <- reactiveValues(v1)
v2vals <- reactiveValues(v2)

observe({

if(input$go > 0) {
v1vals$v1<- levels(data$v1)
v2vals$v2<- levels(data$v2)
}

v1vals$v1<- input$v1
v2vals$v2<- input$v2
})

output$text <- renderText({values$variable})

observe( observeEvent(input$go, {

updatePickerInput(session,"v1",label = "variable 1",
                choices = levels(data$v1),
                selected = levels(data$v1), multiple = TRUE)
}))

observe( observeEvent(input$go, {

updatePickerInput(session, "v2", choices =             
as.character(unique(data[data$v1==input$v1,"v2"])),
options = list(`actions-box` = TRUE), 
multiple = TRUE, selected =levels(data$v2))

}))

})

I am expecting the default selection for v1 and v2 is all levels, and that the filter only updates the rest of the app when the action button is clicked.

khanch94
  • 11
  • 1
  • Your Question is not clear to me... can you explain the requirement?? also I am getting in your code... – Subhasish1315 Jul 11 '19 at 08:30
  • 1
    I have a filter on the side of my dashboard. It filters down a data set. I want it to only filter down the data set when the "apply filters" button is clicked. – khanch94 Jul 16 '19 at 14:50

0 Answers0