【问题标题】:hide tabpanel in R shiny在R闪亮中隐藏标签面板
【发布时间】:2019-01-12 11:22:20
【问题描述】:

伙计们。我有一个关于如何在 R Shiny 中隐藏标签面板的问题。 我在这里阅读了参考资料。 https://shiny.rstudio.com/reference/shiny/1.0.5/showTab.html

然后,我根据这个参考修改了我的代码,但是没有用。 这是我的代码的一部分:

  ui <- fluidPage(

sidebarLayout(
  sidebarPanel(
    conditionalPanel(
    condition = "input.tabselected == 1",
    ....
   actionButton("hideTab","Hide Tab"),
   actionButton("showTab","Show Tab")
  ),

  mainPanel(
      tabsetPanel(type = "tabs",
                tabPanel(title = "D", 
                         value=1),
                tabPanel(title = "S", 
                         value=3),
                tabPanel(title = "Y", 
                         value=2),
                id = "tabselected")
  )

...

      server <- function(input, output) {
  hideTab(inputId = "tabselected", target = "Y")
})

}

与条件面板有什么关系吗?还是可能有其他原因?谢谢你。

【问题讨论】:

    标签: r shiny tabpanel


    【解决方案1】:

    提供给 hideTab 的value 错误:

    ui <- fluidPage(
    
      sidebarLayout(
        sidebarPanel(
          conditionalPanel(
            condition = "input.tabselected == 1",
            actionButton("hideTab","Hide Tab"),
            actionButton("showTab","Show Tab")
          )
        ),
          mainPanel(
            tabsetPanel(type = "tabs",
                        tabPanel(title = "D", 
                                 value=1),
                        tabPanel(title = "S", 
                                 value=3),
                        tabPanel(title = "Y", 
                                 value=2),
                        id = "tabselected")
          )
      )
    )
    
    server <- function(input, output) {
      observeEvent(input$hideTab, {
        hideTab(inputId = "tabselected", target = "2")
      })
    }
    
    shinyApp(ui = ui, server = server)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-10
      • 2018-08-05
      • 2017-11-26
      • 2016-04-10
      • 1970-01-01
      • 2020-07-27
      相关资源
      最近更新 更多