[英]R Shinydashboard Showing/Hiding UI Elements based on Tab selection
I am struggling with a requirement if someone can help. 如果有人可以提供帮助,我正在努力解决这个问题。 I have to show/hide some elements on the Dashboardsidebar based on the tabpanel selection by the user.
我必须根据用户的tabpanel选择显示/隐藏Dashboardsidebar上的一些元素。 Here is part of the UI code to give you an idea of the structure of my app.
以下是UI代码的一部分,可让您了解我的应用程序的结构。 I need to show fourthoutput, fifthout and download button only on tabpPanel 2.
我需要在tabpPanel 2上显示fourthoutput,Fifthout和download按钮。
ui <- dashboardPage(
dashboardHeader(title = "My App"),
dashboardSidebar(
width = 350,
fileInput(
'file1',
'Upload Items List',
accept = c('text/csv',
'text/comma-separated-values,text/plain',
'.csv')
),
fluidRow(column(
width = 2,
offset = 1,
actionButton("goButton", "Submit")
)),
br(),
br(),
uiOutput("FirstOutput"),
uiOutput("SecondOutput"),
uiOutput("ThirdOutput"),
uiOutput("FourthOutput"),
uiOutput("FifthOutput"),
fluidRow(column(
width = 2,
offset = 1,
downloadButton('downloadData', 'Download')))
),
dashboardBody(
tags$style(
type = "text/css",
".shiny-output-error { visibility: hidden; }",
".shiny-output-error:before { visibility: hidden; }"
),
tabsetPanel(
type = "tabs",
tabPanel("1", fluidRow(box(
plotlyOutput("pie1")
),
box(
plotlyOutput("barplot1")
)),
fluidRow(box(
plotlyOutput(outputId = "barplot2")
))),
tabPanel("2",
div(style = 'overflow-x: scroll', dataTableOutput("contents"))
)
)
)
)
thanks, Manoj Agrawal 谢谢,Manoj Agrawal
You have to set an id
to the tabsetPanel
and a value to each tabPanel
. 您必须为
tabsetPanel
设置一个id
,并为每个tabPanel
设置一个值。 Then you can use input.tabsetId
in conditionalPanel
to hide/show the button: 然后你可以使用
input.tabsetId
在conditionalPanel
隐藏/显示按钮:
...
conditionalPanel(
condition = "input.tabs == 'show'",
fluidRow(column(
width = 2,
offset = 1,
downloadButton('downloadData', 'Download'))))
),
...
...
tabsetPanel( id="tabs",
...
tabPanel("1", value="show",
...
tabPanel("2", value="hide",
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.