inst/examples/04-selected/server.R

library(shiny)
library(shinyTree)

#' Define server logic required to generate a simple tree
#' @author Jeff Allen \email{[email protected]@trestletech.com}
shinyServer(function(input, output, session) {
  
  output$tree123 <- renderTree({
    list(
      root1 = structure("123"),
      root2 = list(
        SubListA = list(leaf1 = "", leaf2 = "", leaf3=""),
        SubListB = list(leafA = "", leafB = "")
      )
    )
  })

  output$sel_names <- renderPrint({
    tree <- input$tree123
    req(tree)
    get_selected(tree)
  })
  output$sel_slices <- renderPrint({
    tree <- input$tree123
    req(tree)
    get_selected(tree, format = "slices")
  })
  output$sel_classid <- renderPrint({
    tree <- input$tree123
    req(tree)
    get_selected(tree, format = "classid")
  })
})

Try the shinyTree package in your browser

Any scripts or data that you put into this service are public.

shinyTree documentation built on May 27, 2019, 5 p.m.