【问题标题】:Dynamic Download Button动态下载按钮
【发布时间】:2019-05-24 06:20:26
【问题描述】:

您好,我的 Shiny APP 中的下载按钮有问题。创建相应的 DF 后,我已经动态创建了按钮。现在我有下载不起作用的问题。如果我直接创建了按钮,下载就可以了。 我对重置功能做了同样的事情,一切正常。 谁能告诉我我做错了什么?

这是 UI 中的按钮代码:

column(3, offset = 0, uiOutput("download.action", style = "text-align: center;"))

我的服务器代码如下所示:

    output$download.action <- renderUI({
      div(style = "display:inline-block;width:0%;", actionButton("downloadData", "Download", icon = icon("download"), 
      style = " 
         flex-grow: 1;
        display: inline-block;
        background-color:#999;
        text-decoration: none;
        font-weight: 300;
        border: 1px dash transparent;
        letter-spacing: 0.98pt;
        border-color:#00245d;"))
    })

    output$downloadData <- downloadHandler(
      filename = function() {
        paste("test.xlsx")
      },
      content = function(file) {
        write.xlsx(test3, file, row.names = FALSE)
      }
    )
  })

当我直接创建按钮时,一切正常。

Shiny 不会给出错误消息。只有按钮不起作用。

【问题讨论】:

    标签: r shiny shinydashboard shinyapps


    【解决方案1】:

    您应该将actionButton 替换为downloadButton

    output$download.action <- renderUI({
        div(style = "display:inline-block;width:0%;", downloadButton("downloadData", "Download", icon = icon("download"), 
                                                                   style = " 
                                                                   flex-grow: 1;
                                                                   display: inline-block;
                                                                   background-color:#999;
                                                                   text-decoration: none;
                                                                   font-weight: 300;
                                                                   border: 1px dash transparent;
                                                                   letter-spacing: 0.98pt;
                                                                   border-color:#00245d;"))
      })
    

    【讨论】:

      猜你喜欢
      • 2017-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-06
      相关资源
      最近更新 更多