我正在尝试在我的 R Shiny 应用程序的表格上方添加下载按钮('copy'、'csv'、'excel'、'pdf'),但是在内部使用数据表时,renderDataTable 似乎不起作用。
output$mytable1 <- DT::renderDataTable(
datatable(
{ plots.dfs()[[1]] },
rownames = TRUE,
options = list(
fixedColumns = TRUE,
autoWidth = TRUE,
ordering = FALSE,
dom = 'tB',
buttons = c('copy', 'csv', 'excel', 'pdf')
),
class = "display"
))
当我在没有 DT::datatable 的情况下使用 DT::renderDataTable 时,renderDataTable 运行良好并且我拥有所有功能(过滤器、搜索字段等),除了下载按钮(我要添加的内容)
output$mytable1 = DT::renderDataTable({ plots.dfs()[[1]] })
你知道我做错了什么吗?谢谢你的帮助
最佳答案
正如斯蒂芬在评论中所说,添加按钮的方式如下:
output$mytable1 <- DT::renderDataTable(
DT::datatable(
{ plots.dfs()[[1]] },
extensions = 'Buttons',
options = list(
paging = TRUE,
searching = TRUE,
fixedColumns = TRUE,
autoWidth = TRUE,
ordering = TRUE,
dom = 'tB',
buttons = c('copy', 'csv', 'excel')
),
class = "display"
))
关于r - 在 DT::renderDataTable 中添加下载按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50039186/