横向的闪亮数据表 [英] shiny datatable in landscape orientation

查看:16
本文介绍了横向的闪亮数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下闪亮的代码

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.

根据以下链接:https://datatables.net/reference/button/pdf我们可以将方向作为景观传递.但是,我做不到.

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'


                                                    ))

                                    ))
                    )
            }
    )

这篇关于横向的闪亮数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆