shinydashboard:MenuSubItem文本作为downloadLink

时间:2018-03-07 14:48:39

标签: r shiny shinydashboard

我还没有找到任何解决方案。单击downloadHandler的{​​{1}}时是否可以触发text?那么行为就好像menuSubItem一样?我试过了几件事:  downloadLink  要么 text = downloadLink("dl_object1", "Download object1")  要么 text = shiny::tags$html(downloadLink("dl_object1", "Download object1"))

然而,结果是文本被错误地呈现为text = shiny::htmlOutput("<a id='dl_object1' class='shiny-download-link'>Download object1</a>")或者在点击时没有返回下载对话框。

这是一个用于测试的示例应用程序:

subMenuItem

我也在RStudio GitHub上发布了这个问题,但到目前为止还没有答案。 https://github.com/rstudio/shinydashboard/issues/265

1 个答案:

答案 0 :(得分:0)

以下变通办法适用于IE,Chrome,Firefox,但不适用于Safari 12.0:

  1. downloadLink("dl_object1", ...)放在ui.R中的某个位置,当您单击它时可以使用
  2. 隐藏下载链接,f.i。创建人:document.getElementById("dl_object1").style.visibility = 'hidden';
  3. 点击菜单项时,执行document.getElementById("dl_object1").click();
相关问题