简体   繁体   中英

shinyTree: view without selecting

Consider the following:

library(shiny)
library(shinyTree)
server <- shinyServer(function(input, output, session) {  
  output$tree <- renderTree({ 
    list(  'I lorem impsum'= list( 
      'I.1 lorem impsum'   =  structure(list('I.1.1 lorem impsum'='1', 'I.1.2 lorem impsum'='2'),stselected=TRUE),  
      'I.2 lorem impsum'   =  structure(list('I.2.1 lorem impsum'='3'), stselected=TRUE))) 
  })
})
ui <- shinyUI(
  shiny::fluidPage(
    h4('Shiny hierarchical checkbox')
    ,shinyTree("tree", checkbox = TRUE)
  )
)
shinyApp(ui, server)

在此处输入图片说明

How can I make this so that by default, none of the above are selected but are still displayed ?

If I set both stselected = FALSE in the above code, I get

在此处输入图片说明

which is NOT what I want; I would just like the above with the checkboxes deselected.

Links to online references on further documentation with code would be extremely helpful. The package documentation for shinyTree is not helpful.

You can do it in such way :

output$tree <- renderTree({ 
    sss=list(  'I lorem impsum'= list( 
      'I.1 lorem impsum'   =  structure(list('I.1.1 lorem impsum'='1', 'I.1.2 lorem impsum'='2'),stopened=TRUE),  
      'I.2 lorem impsum'   =  structure(list('I.2.1 lorem impsum'='3'), stopened=TRUE)))
    attr(sss[[1]],"stopened")=TRUE 
    sss
  })

PS

Documentation is realy bad... I find stopened in shinyTree:::getJSON which used in shinyTree:::listToTags

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM