You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to save the state of a jstree, so the user has the possibility to come back later and continue to work on it.
Currently the full input state (e.g. input[["mytree_full"]]) is not updated on expanding a node. However, it is updated when adding a child node via the contextMenu:
library(jsTreeR)
library(shiny)
ui <- fluidPage(
textInput("test", "test"),
jstreeOutput("mytree"),
textOutput("opened")
)
server <- function(input, output, session){
output[["mytree"]] <- renderJstree({
# jstreeDestroy(session, id = "mytree")
nodes <- list(
list(
text = paste0(input$test, "Branch 1"),
state = list(opened = TRUE, disabled = FALSE),
type = "parent",
children = list(
list(text = "Leaf A", type = "child"),
list(text = "Leaf B", type = "child"),
list(text = "Leaf C", type = "child"),
list(text = "Leaf D", type = "child")
)
),
list(text = "Branch 2", type = "parent", state = list(opened = TRUE))
)
jstree(nodes, contextMenu = TRUE)
})
output$opened <- renderText({
if(isTruthy(input[["mytree_full"]])){
paste("Is node 1 opened?:", input[["mytree_full"]][[1]]$state$opened)
}
})
}
shinyApp(ui, server)
The text was updated successfully, but these errors were encountered:
I'd like to save the state of a jstree, so the user has the possibility to come back later and continue to work on it.
Currently the full input state (e.g. input[["mytree_full"]]) is not updated on expanding a node. However, it is updated when adding a child node via the contextMenu:
The text was updated successfully, but these errors were encountered: