首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在shinyTree R中限制单选复选框

如何在shinyTree R中限制单选复选框
EN

Stack Overflow用户
提问于 2017-02-02 20:53:08
回答 1查看 314关注 0票数 1

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

代码语言:javascript
复制
   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,而不选择它的叶子。

EN

回答 1

Stack Overflow用户

发布于 2017-11-09 15:51:00

我不知道一种直接的方法,但作为B计划,你可以拥有这个节点的一个特定的子节点。您将提供一个表示其父对象的名称,您可以在不选择其他children/leaf的情况下选择该名称。

代码语言:javascript
复制
SubListA = list(leafSLA = "SubListA", leaf1 = "", leaf2 = "", leaf3=""),
SubListB = structure(list(leafSLB = "SubListB", leafA = "", leafB = ""),stselected=TRUE)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42002790

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档