问题描述
我对发光仪表板中的条件面板有疑问.是否有可能使条件面板在 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())
这篇关于闪亮仪表板中的条件面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!