Learn R Programming

shinyMobile (version 0.7.0)

updateF7SmartSelect: Change the value of a smart select input on the client

Description

Change the value of a smart select input on the client

Usage

updateF7SmartSelect(
  inputId,
  selected = NULL,
  ...,
  multiple = NULL,
  maxLength = NULL,
  session = shiny::getDefaultReactiveDomain()
)

Arguments

inputId

The id of the input object.

selected

The new value for the input.

...

Parameters used to update the smart select, use same arguments as in f7SmartSelect.

multiple

Whether to allow multiple values.

maxLength

Maximum items to select when multiple is TRUE.

session

The Shiny session object, usually the default value will suffice.

Examples

Run this code
# NOT RUN {
if (interactive()) {
 library(shiny)
 library(shinyMobile)

 shinyApp(
  ui = f7Page(
    title = "My app",
    f7SingleLayout(
      navbar = f7Navbar(title = "Update f7SmartSelect"),
      f7Button("updateSmartSelect", "Update Smart Select"),
      f7SmartSelect(
        inputId = "variable",
        label = "Choose a variable:",
        selected = "drat",
        choices = colnames(mtcars)[-1],
        openIn = "popup"
      ),
      tableOutput("data")
    )
  ),
  server = function(input, output, session) {
    output$data <- renderTable({
      mtcars[, c("mpg", input$variable), drop = FALSE]
    }, rownames = TRUE)

    observeEvent(input$updateSmartSelect, {
      updateF7SmartSelect(
        inputId = "variable",
        openIn = "sheet",
        selected = "cyl",
        multiple = TRUE,
        maxLength = 3
      )
    })
  }
 )
}
# }

Run the code above in your browser using DataLab