【问题标题】:How to restrict a single selection of checkbox in shinyTree R如何在shinyTree R中限制单个复选框的选择
【发布时间】:2017-02-02 12:53:08
【问题描述】:

我正在使用 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 时,它的子项也会被选中。

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

我怎样才能只选择 subListB,而不选择它的叶子。

【问题讨论】:

    标签: r shinyjs shinytree


    【解决方案1】:

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

    SubListA = list(leafSLA = "SubListA", leaf1 = "", leaf2 = "", leaf3=""),
    SubListB = structure(list(leafSLB = "SubListB", leafA = "", leafB = ""),stselected=TRUE)
    

    【讨论】:

      猜你喜欢
      • 2011-03-16
      • 2017-07-20
      • 2011-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-11
      • 1970-01-01
      • 2015-01-19
      相关资源
      最近更新 更多