Is it possible to have only the lowest level children in a shinyTree have a checkbox? In the below screenshot I would like 'Recreational -Fishing' and 'Boat' to not have a checkbox but all the other children to have a checkbox (in screenshot; circles = checkboz, + = no checkbox)?
Thanks!
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)
add to your css:
.jstree li.jstree-open > a.jstree-anchor > i.jstree-checkbox,
.jstree li.jstree-closed > a.jstree-anchor > i.jstree-checkbox {
display:none;
}