ShinyTreeMenuOutput: Render the ShinyTreeMenu HTML

Description Usage Arguments Details See Also Examples

Description

Render a reactive ShinyTreeMenu output variable in your Shiny UI.

Usage

1
2
ShinyTreeMenuOutput(outputId, class = NULL, width = "200px",
  height = "100vh")

Arguments

outputId

output variable to read the value from

class

character; Additional CSS classes to add to the div output

width

character; A valid CSS unit - default is "200px". See details for advanced options. (like "100%" or "400px"). If NULL it will adapt to menu.

height

character; A valid CSS unit - default is "100vh". See details for advanced options.

Details

Width and height:

Besides the normal CSS unit like px, calculation to controle width and height. For example you can set the height of the menu to the screen height minus 50 px, by setting height = "calc(100vh - 50px)"

See Also

renderShinyTreeMenu, updateShinyTreeMenu and ShinyTreeMenuHTML

Examples

 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)
          )
        )
      })


    }

  )

}

emillykkejensen/ShinyTreeMenu documentation built on May 9, 2019, 5:01 a.m.