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,而不选择它的叶子。

4

1 回答 1

0

我不知道直接的方法,但作为 B 计划,您可以拥有该节点的特定子节点。您将给出一个代表其父级的名称,您可以选择而不选择 other children/leaf

SubListA = list(leafSLA = "SubListA", leaf1 = "", leaf2 = "", leaf3=""),
SubListB = structure(list(leafSLB = "SubListB", leafA = "", leafB = ""),stselected=TRUE)
于 2017-11-09T07:50:59.907 回答