Closed philiph99 closed 1 year ago
Noticed that this issue resolves as soon as I use the following data frame and make "Antarctica" and "Luxemburg" clickable manually:
my_cities <- rbind(
shinytreeview::cities,
data.frame(continent = "Luxemburg",
country = NA,
city = NA)
)
args[names(my_cities)[1:2]] <- list(list(selectable = FALSE))
tree <- do.call(make_tree, args)
tree[[5]]$selectable <- NULL # Antarctica
tree[[4]]$selectable <- NULL # Luxemburg
Full code:
library(shiny)
library(shinytreeview)
my_cities <- rbind(
shinytreeview::cities,
data.frame(continent = "Luxemburg",
country = NA,
city = NA)
)
args <- list(
data = my_cities,
levels = c("continent", "country", "city")
)
args[names(my_cities)[1:2]] <- list(list(selectable = FALSE))
tree <- do.call(make_tree, args)
tree[[5]]$selectable <- NULL
tree[[4]]$selectable <- NULL
ui <- fluidPage(
treeviewInput(inputId = "tree", label = "Tree",
choices = tree, selected = "Luxemburg",
multiple = T),
verbatimTextOutput("tree_output")
)
server <- function(input, output, session) {
output$tree_output <- renderText({
input$tree
})
}
shinyApp(ui, server)
After making the first two nodes (continent & country) unselectable, they are now still selected and in the app, I can not unselect them.
What can I do so that in the example below, again only the cities are selectable?
Thank you in advance!
Originally posted by @philiph99 in https://github.com/dreamRs/shinytreeview/issues/11#issuecomment-1564403057