shinyTree: view without selecting

萝らか妹 提交于 2019-12-02 02:47:50

问题


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.


回答1:


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
  })

P.S

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



来源:https://stackoverflow.com/questions/39207559/shinytree-view-without-selecting

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!