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, or a configuration made by shinyfilters().

...

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
updateDateInputDate, POSIXtdefault
updateDateRangeInputDate, POSIXtrange = TRUE
updateNumericInputnumericdefault
updateRadioButtonscharacter, factor, list, logicalradio = TRUE
updateSelectInputcharacter, factor, list, logicaldefault
updateSelectizeInputcharacter, factor, list, logicalselectize = TRUE
updateSliderInputnumericslider = TRUE
updateTextAreaInputcharactertextbox = TRUE, area = TRUE
updateTextInputcharactertextbox = TRUE

Details

The following arguments passed to ... are supported:

area

(character). Logical. Controls whether to use updateTextAreaInput (TRUE) or updateTextInput (FALSE, default). Only applies when textbox is TRUE.

radio

(character, factor, list, logical). Logical. Controls whether to use updateRadioButtons (TRUE) or a dropdown input update function (FALSE, default). For character vectors, radio only applies if textbox is FALSE, the default.

range

(Date, POSIXt). Logical. Controls whether to use updateDateRangeInput (TRUE) or updateDateInput (FALSE, default).

selectize

(character, factor, list, logical). Logical. Controls whether to use updateSelectizeInput (TRUE) or updateSelectInput (FALSE, default). For character vectors, selectize only applies if textbox is FALSE, the default.

slider

(numeric). Logical. Controls whether to use updateSliderInput (TRUE) or 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.

When x is a configuration made by shinyfilters(), each column's input is updated with the function and arguments that match the input filterInput() creates for it: the configuration's defaults, and the input and arguments with_filters() or with_args() set for it, computed from the configuration's data. The arguments that set an input's value (value, selected, start, and end) are left out, and the configuration's namespace is applied to the ids.

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) {
  observe({
    fruits_filtered <- fruits
    if (!is.null(input$letter) && length(input$letter) != 0L) {
      fruits_filtered <- fruits[input$letter]
    }
    # Call updateFilterInput() inside the shiny server:
    updateFilterInput(x = fruits_filtered, inputId = "fruits")
  })
}
shinyApp(ui, server)
}