Description Usage Arguments Details See Also Examples
This function should be run within the Shiny callModule
function and renders a reactive ShinyTreeMenu HTML.
1 | renderShinyTreeMenu(input, output, session, treedata, level_icons)
|
treedata |
data.table; treedata - see |
level_icons |
character; Names of fa-icons to use for the tree - see |
renderShinyTreeMenu is a dynamic HTML rendering function, that
runs within the Shiny callModule
function.
renderShinyTreeMenu renders the initial treemenu as a reactive
Shiny UI Output and this treemenu can then be updated using
updateShinyTreeMenu
.
shinyjs To use ShinyTreeMenu in SHiny, you need to load shinyjs::useShinyjs() in your UI.
ShinyTreeMenuOutput
, updateShinyTreeMenu
and ShinyTreeMenuHTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | if (interactive()) {
shinyApp(
ui = fluidPage(
# ShinyTreeMenu uses shinyjs - so remember to include shinyjs in your UI
shinyjs::useShinyjs(),
ShinyTreeMenuOutput("treemenu")
),
server = function(input, output, session) {
# Treedata has to be in the form of a reactive expression
treedata <- reactive({
ShinyTreeMenu::treetestdata
})
# Use the shiny callModule to render the ShinyTreeMenu
# Note that you should not include () when adding your reactive treedata
shiny::callModule(ShinyTreeMenu::renderShinyTreeMenu,
id = "treemenu",
treedata = treedata,
level_icons = "tree")
# Here you will update the ShinyTreeMenu
# As with the render function, you should not include () when adding your reactive treedata
ShinyTreeMenu::updateShinyTreeMenu(
treedata = treedata,
treemenu_open = reactive({input$treemenu_open}),
level_icons = "tree")
# For the purpose of displaying the selection functionality
observeEvent(input$treemenu, {
showModal(
modalDialog(
paste("Selected id:", input$treemenu$val,
"| Selected level:", input$treemenu$level,
"| Selected row:", input$treemenu$row)
)
)
})
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.