orderInput {shinyjqui} | R Documentation |
Create a shiny input control to show the order of a set of items
Description
Display a set of items whose order can be changed by drag and drop inside or
between orderInput
(s). The item order is send back to server in the from of
input$inputId
.
Usage
orderInput(
inputId,
label,
items,
as_source = FALSE,
connect = NULL,
item_class = c("default", "primary", "success", "info", "warning", "danger"),
placeholder = NULL,
width = "500px",
legacy = FALSE,
...
)
Arguments
inputId |
The |
label |
Display label for the control, or |
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 |
as_source |
A boolean value to determine whether the |
connect |
Optional. Allow items to be dragged between |
item_class |
One of the Bootstrap color utility classes to apply to each item. |
placeholder |
A character string to show when there is no item left in
the |
width |
The width of the input, e.g. '400px', or '100\ shiny::validateCssUnit. |
legacy |
A boolean value. Whether to use the old version of the
|
... |
Arguments passed to |
Details
orderInput
s can work in either connected mode or stand-alone mode. In
stand-alone mode, items can only be drag and drop inside the input control.
In connected mode, items to be dragged between orderInput
s, which is
controlled by the connect
parameter. This is a one-way relationship. To
connect items in both directions, the connect
parameter must be set in both
orderInput
s.
When in connected mode, orderInput
can be set as source-only through the
as_source
parameter. The items in a "source" orderInput
can only be
copied, instead of moved, to other connected non-source orderInput
(s). From
shinyjqui v0.4.0, A "source" orderInput
will become a "recycle bin" for
items from other orderInput
s as well. This means, if you want to delete an
item, you can drag and drop it into a "source" orderInput
. This feature can
be disabled by setting the options
of non-source orderInput
(s) as
list(helper = "clone")
.
From shinyjqui v0.4.0 and above, the orderInput
function was implemented in
the similar way as other classical shiny inputs, which brought two changes:
The input value was changed from
input$inputId_order
toinput$inputId
;The new version supports updateOrderInput function which works in the same way as other shiny input updater functions. To keep the backward compatibility, a
legacy
argument was provided if user wanted to use the old version.
Value
An orderInput
control that can be added to a UI definition.
Examples
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...')