I am using shinyTree package and its checkbox option.

library(shiny)
    library(shinyTree)

    server <- shinyServer(function(input, output, session) {
      # Defining lists inside list and rendering it in the shinyTree
      output$tree <- renderTree({
        list(
          root1 = "123",
          root2 = list(
            SubListA = list(leaf1 = "", leaf2 = "", leaf3=""),
            SubListB = structure(list(leafA = "", leafB = ""),stselected=TRUE)
          )
        )
      })
    })

    ui <- shinyUI(
      pageWithSidebar(
        # Application title
        headerPanel("shinyTree with checkbox controls"),
        sidebarPanel(
         mainPanel(
          # Show a simple table with checkbox.
          shinyTree("tree", checkbox = TRUE)
      ))
    )

shinyApp(ui, server)

While running the above code, while selecting the sublistB the child of it also gets selected.

SublistB was selected but the child leafA and leafB also are selected

How can I only select subListB, and not selecting its leaves. Just like what happens when we use simple select property of shinyTree.

library(shiny)
library(shinyTree)
server <- shinyServer(function(input, output, session) {
  output$tree <- renderTree({
    list(
      root1 = "",
      root2 = list(
        SubListA = list(leaf1 = "", leaf2 = "", leaf3=""),
        SubListB = list(leafA = "", leafB = "")
      )
    )
  })
})
ui<-shinyUI(
  pageWithSidebar(
    # Application title
    headerPanel("Simple shinyTree!"),
     sidebarPanel(
    mainPanel(
      # Show a simple table.
      shinyTree("tree")
    )
  ))
shinyApp(ui, server) 

Simple shinyTree selection of only parent node SubListB and not the child nodes leafA and leafB

0

There are 0 best solutions below