闪亮仪表板中的条件面板 [英] Conditional panel in Shiny dashboard

查看:49
本文介绍了闪亮仪表板中的条件面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对发光仪表板中的条件面板有疑问.是否有可能使条件面板在 sidebarMenu 中的 menuItem 上具有条件?我的目标是在单击菜单选项卡 title2 后获得一个附加的 selectInput (但对于 title1 选项卡应该保持不可见).

I have a question about conditional panel in shiny dashboard. Is there a possibility to make conditional panel with condition on menuItem in sidebarMenu? My goal is to obtain an additional selectInput after click on menu tab title2 (but it should stay invisible for title1 tab).

我正在执行以下操作

ui <- dashboardPage(
    dashboardHeader(title = "Basic Dashboard"),
    dashboardSidebar(
        sidebarMenu(
            menuItem("tab title1", tabName = "name1", icon = icon("th")),
            menuItem("tab title2", tabName =  "name2", icon = icon("th"))
         ),
        conditionalPanel(
            condition = "input.tabName == 'name2'",
            selectInput("period", "Period:", 
                        choices = list("Years" = 1, "Months" = 2))
        )
        ),
    dashboardBody())

在标准的 shiny 中,可以通过在选项卡上添加,value = 1 来完成此操作,但此操作不起作用.有谁知道解决方案吗?在此先感谢:)

In standard shiny it could be done by add , value=1 to tab but here it doesn't work. Does anyone know any solution? Thanks in advance :)

推荐答案

sidebarMenu 添加一个额外的参数 id 解决了该问题.

Adding an extra argument id to sidebarMenu solves the problem.

ui <- dashboardPage(
dashboardHeader(title = "Basic Dashboard"),
dashboardSidebar(
    sidebarMenu(id="menu1",
        menuItem("tab title1", tabName = "name1", icon = icon("th")),
        menuItem("tab title2", tabName =  "name2", icon = icon("th"))
     ),
    conditionalPanel(
        condition = "input.menu1 == 'name2'",
        selectInput("period", "Period:", 
                    choices = list("Years" = 1, "Months" = 2))
    )
    ),
dashboardBody())

这篇关于闪亮仪表板中的条件面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆