首页 > 解决方案 > 在闪亮的应用程序中更改选项卡面板中的下载按钮位置

问题描述

我正在开发一个闪亮的应用程序并使用mainPanel()带有选项卡面板的。第一个tabPanel()应该包含 atableOutput()和 a downloadButton()downloadButton()如下图所示对齐。

只有当输出表产生时,它才会下降。我希望它从一开始就与表格底部对齐。我应该在我的代码中更改什么?

这是代码:

ui <- fluidPage(

                sidebarLayout(
                  sidebarPanel(
                        selectizeInput(inputId = "gender1",
                                  label = "Choose samples to compare",
                                  choices = genders,
                                  options = list(
                                    placeholder = 'Sample 1',
                                    onInitialize = I('function() { this.setValue(""); }'))),
                         conditionalPanel("input.gender1 != ''",
                            selectizeInput(inputId = "gender2",
                                      label = NULL,
                                      choices = '',
                                      options = list(
                                        placeholder = 'Sample 2',
                                        onInitialize = I('function() { this.setValue(""); }')))),
                         actionButton(inputId = "button", label = "Plot", 
                                 style="color: #fff; background-color: #337ab7; border-color: #2e6da4"))),

                    mainPanel(
                        tabsetPanel(
                          tabPanel("Table", tableOutput("table"),
                                   downloadButton("download", "Download", 
                                                  style="color: #fff; background-color: green; border-color: Black;")),
                          tabPanel("Volcano Plot", plotOutput("vplot",width = "550px", height="350px")),
                          tabPanel("PCA Plot", plotOutput("pcaplot",width = "550px", height="350px")),
                          tabPanel("Heatmap",plotOutput("hplot",width = "550px", height="350px")),
                          tabPanel("Manhattan plot", plotOutput("mplot"))
                    )
                    )))

server <- function(input, output,session) {
observe({
    input$gender1
    updateSelectizeInput(session, 'gender2',choices = genders[genders != input$gender1],options = list(
      placeholder = 'Sample 2',
      onInitialize = I('function() { this.setValue(""); }')))
  })
observeEvent(input$button,{output$table <- renderTable({isolate(fitData(input$gender1,input$gender2))})

output$download <- downloadHandler(
    filename = function(){paste(input$gender1,inputSamples,".csv",sep = ' with ')},
    content = function(file){
      write.csv(fittable(),file)})

shinyApp(ui = ui, server = server)

标签: rshiny

解决方案


尝试这个

tabPanel("Table",
         fluidRow(column(10,tableOutput("table")),
                  column(3, style = "margin-top: 500px;",
                         downloadButton("download", "Download",
                         style="color: #fff; background-color: green; border-color: Black;"))
         )),

您应该将边距更改为表格输出的高度。我给了500px。


推荐阅读