1

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

谢谢!

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)

截屏

4

3 回答 3

3

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

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

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

在此处输入图像描述

于 2021-11-24T08:12:02.320 回答
1

添加到您的CSS:

.jstree li.jstree-open > a.jstree-anchor > i.jstree-checkbox,
.jstree li.jstree-closed > a.jstree-anchor > i.jstree-checkbox {
   display:none; 
}
于 2021-12-08T08:15:10.420 回答
0

在我的情况下,我只想禁用顶层的复选框,所以我的 ui 看起来像:

ui <- fluidPage(
    tags$head(
        tags$style(
            HTML("
            div.jstree > ul.jstree-children > li > a.jstree-anchor > i.jstree-checkbox {
                display:none; 
            }")
        )
    ),
    .
    .
    .
于 2022-02-15T03:10:12.760 回答