Skip to contents

Similar to the input updater functions of shiny package, this function send a message to the client, telling it to change the settings of an orderInput object. Any arguments with NULL values will be ignored; they will not result in any changes to the input object on the client. The function can't update the "source" orderInputs.

Usage

updateOrderInput(
  session,
  inputId,
  label = NULL,
  items = NULL,
  connect = NULL,
  item_class = NULL
)

Arguments

session

The session object passed to function given to shinyServer.

inputId

The input slot that will be used to access the current order of items.

label

Display label for the control, or NULL for no label.

items

Items to display, can be a list, an atomic vector or a factor. For list or atomic vector, if named, the names are displayed and the order is given in values. For factor, values are displayed and the order is given in levels

connect

Optional. Allow items to be dragged between orderInputs. Should be a vector of inputId(s) of other orderInput(s) that the items from this orderInput should be connected to.

item_class

One of the Bootstrap color utility classes to apply to each item.

Examples

library(shiny)

if (interactive()) {

  ui <- fluidPage(
    orderInput("foo", "foo",
               items = month.abb[1:3],
               item_class = 'info'),
    verbatimTextOutput("order"),
    actionButton("update", "update")
  )

  server <- function(input, output, session) {
    output$order <- renderPrint({input$foo})
    observeEvent(input$update, {
      updateOrderInput(session, "foo",
                       items = month.abb[1:6],
                       item_class = "success")
    })
  }

  shinyApp(ui, server)

}