1

我正在使用 shinyTree 包及其复选框选项。

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)

在运行上面的代码时,在选择 sublistB 时,它的子项也会被选中。

选择了子列表 B,但也选择了子叶子 A 和叶子 B

我怎样才能只选择 subListB,而不选择它的叶子。就像我们使用 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) 

仅选择父节点 SubListB 而不是子节点 LeafA 和 LeafB 的简单闪亮树选择

4

0 回答 0