如果有人可以提供帮助,我正在努力解决这个问题。我必须根据用户的tabpanel选择显示/隐藏Dashboardsidebar上的一些元素。以下是UI代码的一部分,可让您了解我的应用程序的结构。我只需要在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"))
)
)
)
)
感谢, Manoj Agrawal
答案 0 :(得分:6)
您必须将id
设置为tabsetPanel
,并为每个tabPanel
设置一个值。然后,您可以使用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",
...