横向的闪亮数据表

编程入门 行业动态 更新时间:2024-10-27 08:33:49
本文介绍了横向的闪亮数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下闪亮的代码

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/reference/button/pdf我们可以将方向作为景观传递.但是,我做不到.

According to following link: https://datatables/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屋!

更多推荐

[db:关键词]

本文发布于:2023-03-28 04:51:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/717657.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:横向   数据表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!