View source: R/input-treeview.R
treeviewInput | R Documentation |
Represent hierarchical tree structures to select a value in a nested list.
treeviewInput(
inputId,
label = NULL,
choices,
selected = NULL,
multiple = FALSE,
levels = 1,
borders = TRUE,
prevent_unselect = FALSE,
...,
nodes_input = FALSE,
return_value = c("name", "id", "all"),
width = NULL
)
inputId |
The |
label |
Display label for the control, or |
choices |
A |
selected |
Default selected value, must correspond to the Id of the node. |
multiple |
Allow selection of multiple values. |
levels |
Sets the number of hierarchical levels deep the tree will be expanded to by default. |
borders |
Show or not borders around items. |
prevent_unselect |
When |
... |
Others parameters passed to JavaScript treeview method. |
nodes_input |
Send nodes data through an input value : |
return_value |
Value returned server-side, default is the element name,
other possibilities are |
width |
The width of the input, e.g. |
Server-side: A character
value or a list
depending on the return_value
argument.
updateTreeview()
and others functions to manipulate tree server-side.
# Basic treeviewInput example --------------------------
library(shiny)
library(shinytreeview)
choices <- list(
list(
text = "Parent 1",
nodes = list(
list(text = "Child 1.1"),
list(text = "Child 1.2")
)
),
list(text = "Parent 2"),
list(text = "Parent 3"),
list(
text = "Parent 4",
nodes = list(
list(text = "Child 4.1"),
list(text = "Child 4.2")
)
),
list(text = "Parent 5")
)
ui <- fluidPage(
tags$h3("treeviewInput basic example"),
treeviewInput(
inputId = "tree", label = "Make a choice:",
choices = choices, selected = "Parent 3",
multiple = FALSE, prevent_unselect = TRUE
),
verbatimTextOutput(outputId = "result")
)
server <- function(input, output, session) {
output$result <- renderPrint({
input$tree
})
}
if (interactive())
shinyApp(ui, server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.