本文介绍了闪亮的datatable在横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有如下的代码:
DT::renderDataTable({
df()
, rownames=FALSE
,extensions = c('Responsive', 'Buttons')
, options = list(
# dom = 'C<"clear">T<"clear">lfrtip'
# , tableTools=list(sSwfPath = copySWF('www'))
dom = 'Bfrtip'
, buttons = c('pageLength'
, 'colvis'
, 'pdf')
, orientation ='landscape'
, lengthMenu = list(c(6, 12, 18, -1), c('6', '12', '18', 'All'))
, pageLength = 12
)
)
}
})
我想在景观中下载pdf。我应该怎么做
I want to download pdf in landscape. How should I do it.
根据以下链接:,我们可以将方向作为景观。但是,我不能这样做。
According to following link: https://datatables.net/reference/button/pdf that we can pass orientation as landscape. However, I am not able to do it.
我尝试过以下操作:
DT::renderDataTable({
df()
, rownames=FALSE
,extensions = c('Responsive', 'Buttons')
, options = list(
# dom = 'C<"clear">T<"clear">lfrtip'
# , tableTools=list(sSwfPath = copySWF('www'))
dom = 'Bfrtip'
, buttons = c('pageLength'
, 'colvis'
, list(extend: 'pdf', orientation='landscape')
, orientation ='landscape'
, lengthMenu = list(c(6, 12, 18, -1), c('6', '12', '18', 'All'))
, pageLength = 12
)
)
}
})
推荐答案
这对我有用。由于您没有提供数据,因此我使用了iris数据集。不是pdf在横向,但表不使用所有可用空间,但行为与。它不适用于RStudio,但它在浏览器中(Firefox 49.0)
This works for me. Since you didn't provide the data I used the iris dataset. Not the the pdf is in landscape orientation but the table does not use all the available space, but the behavior is the same as in the datatables example. It does not work from RStudio, but it does in the browser (Firefox 49.0)
这是代码:
library(shiny)
library(DT)
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(
datatable(
iris,
rownames = FALSE,
extensions = c('Responsive', 'Buttons'), options = list(
pageLength = 12,
orientation ='landscape',
lengthMenu = list(c(6, 12, 18, -1), c('6', '12', '18', 'All')),
dom = 'Bfrtip',
buttons =
list('pageLength', 'colvis', list(
extend = 'pdf',
pageSize = 'A4',
orientation = 'landscape',
filename = 'tt'
))
))
)
}
)
这篇关于闪亮的datatable在横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!