Closed castledan closed 1 year ago
Hello, Thanks for reporting this issue. Should be fixed if you re-install from GitHub:
remotes::install_github("dreamRs/shinytreeview")
One small change with your example: selected =
argument must be used in treecheckInput()
not in make_tree()
, e.g. :
library(shiny)
library(shinytreeview)
data("cities")
ui <- fluidPage(
treecheckInput(
inputId = "tree",
choices = make_tree(
cities,
c("continent", "country", "city")
),
selected = "Africa"
),
verbatimTextOutput(outputId = "result")
)
server <- function(input, output, session) {
output$result <- renderPrint({
input$tree
})
}
if (interactive())
shinyApp(ui, server)
Victor
Hi Victor,
Thank you for your reply. The selection works now.
However, I just found something else. If you run the code snippet below, the node (New continent)
does not get selected. After some trials with special characters, I found out this has to do with the use of the brackets (
. Can this be fixed?
Also, is there a way to change the value of the tree input on the client? Something like what updateCheckboxGroupInput
does for checkboxGroupInput
.
library(shiny)
library(shinytreeview)
data("cities")
cities <- rbind(cities, c('(New continent)', 'New country', 'New city'))
ui <- fluidPage(
treecheckInput(
inputId = "tree",
choices = make_tree(
cities,
c("continent", "country", "city")
),
selected = cities$continent
),
verbatimTextOutput(outputId = "result")
)
server <- function(input, output, session) {
output$result <- renderPrint({
input$tree
})
}
if (interactive())
shinyApp(ui, server)
Ah yes, actually it search a reg exp with the name of the node, I have escaped special characters, should work now.
Thank you! I posted the other question as a new issue, as I figured it was off-topic here.
Perfect, thank you, I will take a look later
Hi,
Thank you for this package, it's very useful.
I do not manage to select nodes by default when using
treecheckInput
. When running the code below, no nodes get selected in my shiny app. If I usetreeviewInput
instead, with the same code, all main nodes get selected.Any idea?