We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi @pvictor ,
Thank you so much for this package.
Is there a way in which the menu can automatically collapse back once a country is selected?
` library(shiny) library(shinytreeview)
data("cities")
ui <- fluidPage( tags$h3("treeviewInput cities example"), treeviewInput( inputId = "tree", label = "Choose a city:", choices = make_tree( cities, c("continent", "country", "city") ), multiple = FALSE, prevent_unselect = TRUE, width = "100%" ), verbatimTextOutput(outputId = "result") )
server <- function(input, output, session) { output$result <- renderPrint({ input$tree }) }
if (interactive()) shinyApp(ui, server) `
The text was updated successfully, but these errors were encountered:
Hi,
You can collapse levels from your server with collapseTreeview().
collapseTreeview()
There's two solutions :
collapseTreeview("tree") # "tree" is inputId of the widget
nodes <- input$tree_nodes this_node <- nodes[nodes$text == input$tree, "parentId"] collapseTreeview("tree", nodeId = this_node)
Here's an example:
library(shiny) library(shinytreeview) data("cities") ui <- fluidPage( tags$h3("treeviewInput cities example"), treeviewInput( inputId = "tree", label = "Choose a city:", choices = make_tree( cities, c("continent", "country", "city") ), multiple = FALSE, prevent_unselect = TRUE, width = "100%" ), verbatimTextOutput(outputId = "result"), verbatimTextOutput(outputId = "nodes") ) server <- function(input, output, session) { observeEvent(input$tree, { if (input$tree %in% cities$city) { nodes <- input$tree_nodes this_node <- nodes[nodes$text == input$tree, "parentId"] collapseTreeview("tree", nodeId = this_node) # or collapse all levels with: # collapseTreeview("tree") } }) output$result <- renderPrint({ input$tree }) output$nodes <- renderPrint({ input$tree_nodes }) } if (interactive()) shinyApp(ui, server)
Victor
Sorry, something went wrong.
Hi @pvictor that worked ... thank you.
No branches or pull requests
Hi @pvictor ,
Thank you so much for this package.
Is there a way in which the menu can automatically collapse back once a country is selected?
`
library(shiny)
library(shinytreeview)
data("cities")
ui <- fluidPage(
tags$h3("treeviewInput cities example"),
treeviewInput(
inputId = "tree",
label = "Choose a city:",
choices = make_tree(
cities, c("continent", "country", "city")
),
multiple = FALSE,
prevent_unselect = TRUE,
width = "100%"
),
verbatimTextOutput(outputId = "result")
)
server <- function(input, output, session) {
output$result <- renderPrint({
input$tree
})
}
if (interactive())
shinyApp(ui, server)
`
The text was updated successfully, but these errors were encountered: