首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >您可以在r中创建带有复选框的shinyTree,但只有子复选框才有复选框吗?

您可以在r中创建带有复选框的shinyTree,但只有子复选框才有复选框吗?
EN

Stack Overflow用户
提问于 2021-11-24 07:25:22
回答 3查看 196关注 0票数 1

是否有可能在shinyTree中只有最低级别的子级有一个复选框?在下面的截图中,我希望‘休闲-Fishing’和'Boat‘没有一个复选框,但是其他所有的孩子都有一个复选框(在屏幕截图中;圆形= checkboz,+= no复选框)?

谢谢!

代码语言:javascript
复制
library(shiny)
library(shinyTree)

# Create tree data ----
tree.data <-    list(
  'Recreational - Fishing' = structure(list(
    'Boat' = structure(list(
      'Cray pot'= structure("",sttype="default",sticon="glyphicon glyphicon-record"),
      'Hand/rod & line' = structure("",sttype="default",sticon="glyphicon glyphicon-record"),
      'Cray loop' = structure("",sttype="default",sticon="glyphicon glyphicon-record"),
      'Drop net' = structure("",sttype="default",sticon="glyphicon glyphicon-record"),
      'Spear' = structure("",sttype="default",sticon="glyphicon glyphicon-record"),
      'Other' = structure("",sttype="default",sticon="glyphicon glyphicon-record")),
      sttype="default",stopened=FALSE,sticon="glyphicon glyphicon-plus", stdisabled=TRUE)),
    sttype="default",stopened=FALSE,sticon="glyphicon glyphicon-plus")
  )

# UI ----
ui <- fluidPage(
    sidebarLayout(
        sidebarPanel(
          shinyTree("tree", checkbox = TRUE, search=TRUE, searchtime = 1000)
        ),

        # Show a plot of the generated distribution
        mainPanel(
           
        )
    )
)

#Server ----
server <- function(input, output) {

  # Render Tree
  output$tree <- renderTree({
    tree.data
  })
}

# Run the application 
shinyApp(ui = ui, server = server)

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-12-08 08:15:10

添加到css中:

代码语言:javascript
复制
.jstree li.jstree-open > a.jstree-anchor > i.jstree-checkbox,
.jstree li.jstree-closed > a.jstree-anchor > i.jstree-checkbox {
   display:none; 
}
票数 1
EN

Stack Overflow用户

发布于 2021-11-24 08:12:02

您可以将以下css添加到您闪亮的应用程序中,以隐藏shinyTree中的一些复选框:

代码语言:javascript
复制
#\31 _anchor > .jstree-checkbox {
    display: none;
}

#\32 _anchor > .jstree-checkbox {
    display: none;
}

票数 3
EN

Stack Overflow用户

发布于 2022-02-15 03:10:12

在我的例子中,我只想在顶层禁用复选框,所以我的ui看起来如下:

代码语言:javascript
复制
ui <- fluidPage(
    tags$head(
        tags$style(
            HTML("
            div.jstree > ul.jstree-children > li > a.jstree-anchor > i.jstree-checkbox {
                display:none; 
            }")
        )
    ),
    .
    .
    .
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70092100

复制
相关文章

相似问题

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