| objectListInput | R Documentation |
Displays the selected objects as a vertical list; entries can be dragged to
re-order and removed with the X button on the right. The value is a
character vector of the entry keys, in the order shown on screen.
Implemented using vanilla shiny selectizeInput, hence
no additional 'JavaScript' library is needed.
objectListInput(
inputId,
label = NULL,
choices = NULL,
selected = NULL,
width = NULL,
placeholder = "(No object selected)",
sortable = TRUE,
removable = TRUE,
allow_readd = TRUE
)
updateObjectListInput(
session = shiny::getDefaultReactiveDomain(),
inputId,
label = NULL,
choices = NULL,
selected = choices
)
inputId, label, width |
passed to |
choices |
a named list or character vector of the entries; the names are
the text displayed in each row and the values are the entry keys returned by
the input; the order of |
selected |
keys of the entries to show; default is all of
|
placeholder |
text to display when the list is empty |
sortable |
whether the entries can be dragged to re-order; requires 'jQuery' shipped with shiny, and is silently disabled when unavailable |
removable |
whether each entry has a button to remove itself |
allow_readd |
whether the entries can be selected again from a
drop-down menu; when |
session |
shiny session |
objectListInput returns a shiny input; the input value is a
character vector of the entry keys in display order.
updateObjectListInput is called for its side effect.
ui <- shiny::basicPage(
objectListInput(
inputId = "objects", label = "Selected objects",
choices = character(),
selected = character()
),
shiny::actionButton("btn", "Add")
)
if (interactive()) {
shiny::shinyApp(
ui = shiny::fluidPage(ui, shiny::verbatimTextOutput("selected")),
server = function(input, output, session) {
output$selected <- shiny::renderPrint({ input$objects })
shiny::bindEvent(
shiny::observe({
shidashi::updateObjectListInput(
inputId = "objects",
choices = c(
"Electrode 1 [LA1]" = "elec_1",
"Streamlines [n=12]" = "streamlines_1",
"Overlay aparc [discrete]" = "volume_1"
)
)
}),
input$btn
)
}
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.