你能用复选框在 r 中创建一个 shinyTree 但只有 children 有复选框吗?
Can you create a shinyTree in r with checkbox but only the children have checkboxes?
是否可以只在 shinyTree 中的最低级别 children 有一个复选框?
在下面的屏幕截图中,我希望 'Recreational -Fishing' 和 'Boat' 没有复选框,但所有其他 children 有一个复选框(在屏幕截图中;圆圈 = 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)
您可以将以下 css 添加到您的 shiny 应用程序中以隐藏 shinyTree 中的一些复选框:
# _anchor > .jstree-checkbox {
display: none;
}
# _anchor > .jstree-checkbox {
display: none;
}
添加到您的 css:
.jstree li.jstree-open > a.jstree-anchor > i.jstree-checkbox,
.jstree li.jstree-closed > a.jstree-anchor > i.jstree-checkbox {
display:none;
}
在我的例子中,我只想禁用顶层的复选框,所以我的 ui 看起来像:
ui <- fluidPage(
tags$head(
tags$style(
HTML("
div.jstree > ul.jstree-children > li > a.jstree-anchor > i.jstree-checkbox {
display:none;
}")
)
),
.
.
.
是否可以只在 shinyTree 中的最低级别 children 有一个复选框? 在下面的屏幕截图中,我希望 'Recreational -Fishing' 和 'Boat' 没有复选框,但所有其他 children 有一个复选框(在屏幕截图中;圆圈 = 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)
您可以将以下 css 添加到您的 shiny 应用程序中以隐藏 shinyTree 中的一些复选框:
# _anchor > .jstree-checkbox {
display: none;
}
# _anchor > .jstree-checkbox {
display: none;
}
添加到您的 css:
.jstree li.jstree-open > a.jstree-anchor > i.jstree-checkbox,
.jstree li.jstree-closed > a.jstree-anchor > i.jstree-checkbox {
display:none;
}
在我的例子中,我只想禁用顶层的复选框,所以我的 ui 看起来像:
ui <- fluidPage(
tags$head(
tags$style(
HTML("
div.jstree > ul.jstree-children > li > a.jstree-anchor > i.jstree-checkbox {
display:none;
}")
)
),
.
.
.