Skip to contents

Updates a shiny input based the type of object x and other arguments.

Usage

updateFilterInput(x, ...)

Arguments

x

The object used to create the input.

...

Arguments used for input selection or passed to the selected input update function. See details.

Value

The result of the following shiny input updates is returned, based on the type of object passed to x, and other specified arguments.

ValuexArguments
shiny::updateDateInputDate, POSIXtdefault
shiny::updateDateRangeInputDate, POSIXtrange = TRUE
shiny::updateNumericInputnumericdefault
shiny::updateRadioButtonscharacter, factor, list, logicalradio = TRUE
shiny::updateSelectInputcharacter, factor, list, logicaldefault
shiny::updateSelectizeInputcharacter, factor, list, logicalselectize = TRUE
shiny::updateSliderInputnumericslider = TRUE
shiny::updateTextAreaInputcharactertextbox = TRUE, area = TRUE
shiny::updateTextInputcharactertextbox = TRUE

Details

The following arguments passed to ... are supported:

area(character). Logical. Controls whether to use shiny::updateTextAreaInput (TRUE) or shiny::updateTextInput (FALSE, default). Only applies when textbox is TRUE.
range(Date, POSIXt). Logical. Controls whether to use shiny::updateDateRangeInput (TRUE) or shiny::updateDateInput (FALSE, default).
selectize(character, factor, list, logical). Logical. Controls whether to use shiny::updateSelectizeInput (TRUE) or shiny::updateSelectInput (FALSE, default). For character vectors, selectize only applies if textbox is FALSE, the default.
slider(numeric). Logical. Controls whether to use shiny::updateSliderInput (TRUE) or shiny::updateNumericInput (FALSE, default) .
textbox(character). Logical. Controls whether to update a text input (TRUE) or a dropdown input (FALSE, default).

Remaining arguments passed to ... are passed to args_update_filter_input() or the selected input update function.

Examples

if (FALSE) { # interactive()
library(shiny)

fruits <- list(
  "a" = c("apples", "avocados"),
  "b" = c("bananas", "blueberries"),
  "c" = c("cherries", "cantaloupe")
)

ui <- fluidPage(
  sidebarLayout(
    sidebarPanel(
      filterInput(
        x = letters[1:3],
        inputId = "letter",
        label = "Pick a letter:",
       multiple = TRUE
      ),
      filterInput(
        x = fruits,
        inputId = "fruits",
        label = "Pick a fruit:"
      )
    ),
   mainPanel()
  )
)

server <- function(input, output, session) {
  shiny::observe({
    fruits_filtered <- fruits
    if (!is.null(input$letter) && length(input$letter) != 0L) {
      fruits_filtered <- fruits[input$letter]
    }
    #########################################################
    # 2. Call updateFilterInput() inside the shiny server:
    updateFilterInput(x = fruits_filtered, inputId = "fruits")
    #########################################################
  })
}
shinyApp(ui, server)
}