shinyjqui (version 0.3.3)

orderInput: A shiny input control to show the order of a list of items

Description

Display a list items whose order can be changed by drag and drop within or between orderInput(s). The current items order can be obtained from input$inputId_order.

Usage

orderInput(
  inputId,
  label,
  items,
  as_source = FALSE,
  connect = NULL,
  item_class = c("default", "primary", "success", "info", "warning", "danger"),
  placeholder = NULL,
  width = "500px",
  ...
)

Arguments

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 and 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

as_source

A boolean value to determine whether the orderInput is set as source mode. If source mode, items in this orderInput can only be dragged (copied) to the connected non-source orderInput(s) defined by connect argument. If non-source mode, items in the orderInput can be dragged (moved) within or toward other connected non-source orderInput(s) defined by connect argument.

connect

optional, a vector of inputId(s) of other orderInput(s) that the current orderInput connects to. The behavior of the connected orderInput(s) depend on the as_source argument.

item_class

One of the Bootstrap Button Styles to apply to each item.

placeholder

A character string to show when there is no item left in the orderInput.

width

The width of the input, e.g. '400px', or '100\ validateCssUnit.

...

Arguments passed to shiny::tags$div which is used to build the container of the orderInput.

Value

A orderInput control that can be added to a UI definition.

Examples

Run this code
# NOT RUN {
orderInput('items1', 'Items1', items = month.abb, item_class = 'info')

## build connections between orderInputs
orderInput('items2', 'Items2 (can be moved to Items1 and Items4)', items = month.abb,
           connect = c('items1', 'items4'), item_class = 'primary')

## build connections in source mode
orderInput('items3', 'Items3 (can be copied to Items2 and Items4)', items = month.abb,
           as_source = TRUE, connect = c('items2', 'items4'), item_class = 'success')

## show placeholder
orderInput('items4', 'Items4 (can be moved to Items2)', items = NULL, connect = 'items2',
           placeholder = 'Drag items here...')
# }

Run the code above in your browser using DataLab