2017-02-02 18 views
0

shinyTreeパッケージとそのチェックボックスオプションを使用しています。shinyTreeのチェックボックスを1つだけに制限する方法R

library(shiny) 
    library(shinyTree) 

    server <- shinyServer(function(input, output, session) { 
     # Defining lists inside list and rendering it in the shinyTree 
     output$tree <- renderTree({ 
     list(
      root1 = "123", 
      root2 = list(
      SubListA = list(leaf1 = "", leaf2 = "", leaf3=""), 
      SubListB = structure(list(leafA = "", leafB = ""),stselected=TRUE) 
     ) 
     ) 
     }) 
    }) 

    ui <- shinyUI(
     pageWithSidebar(
     # Application title 
     headerPanel("shinyTree with checkbox controls"), 
     sidebarPanel(
     mainPanel(
      # Show a simple table with checkbox. 
      shinyTree("tree", checkbox = TRUE) 
    )) 
    ) 

shinyApp(ui, server) 

上記のコードを実行しているときに、サブリストBを選択しているときにその子も選択されます。

SublistB was selected but the child leafA and leafB also are selected

どのように私はsubListBを選択し、その葉を選択することはできません。

答えて

0

私は直接的な方法はわかりませんが、プランBとして、このノードの特定の子を持つことができます。あなたはその親を表す名前を与え、他のものを選択せず​​に選択することができますchildren/leaf

SubListA = list(leafSLA = "SubListA", leaf1 = "", leaf2 = "", leaf3=""), 
SubListB = structure(list(leafSLB = "SubListB", leafA = "", leafB = ""),stselected=TRUE) 
関連する問題