按钮:带滚动条的下载按钮仅下载几行 [英] Buttons: download button with scroller downloads only few rows

查看:62
本文介绍了按钮:带滚动条的下载按钮仅下载几行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理具有超过100000行的表,并使用 DT 包(开发版本0.1.56 )在Shiny App中对其进行可视化处理。

I am handling tables with more than 100 000 rows and using DT package (development version 0.1.56) to visualize it in Shiny App.

此外,我将 DT 扩展名用作:按钮 ,以不同格式下载数据。但是,虽然同时激活了 Scroller 扩展名,但我只能下载几行(不是所有数据)。

Furthermore I am using DT Extensions as: Buttons, to download the data in different formats. However while Scroller extension is as well activated, i am able only to download few rows (not all data).

示例代码:

library("shiny")
library("DT")

shinyApp(
  ui = fluidPage(DT::dataTableOutput('tbl')),
  server = function(input, output) {
    output$tbl = DT::renderDataTable(
      iris,extensions=c("Buttons",'Scroller'),options = list(dom = 'Bfrtip',
                                               buttons = c('copy', 'csv', 'excel', 'pdf', 'print'),scrollY = 50,
                                               scroller = TRUE
      ))
  }
)

另外,如果我仅在R中运行这部分代码并在查看器中获取数据表,我能够复制等所有行,那怎么可能呢? / p>

Additionally if i run only this part of the code in R and get the datatable in the viewer, i am able to copy etc. all rows, how it is even possible?

library("DT")
datatable(
  iris,
  extensions = 'Buttons', options = list(
    dom = 'Bfrtip',
    buttons = c('copy', 'csv', 'excel', 'pdf', 'print')
  )
)

我尝试了不同的方法:


  1. 更改 scrollY = ...在选项列表中->它正在工作,但是 scrollY 的数量必须很大才能实际显示所有数据行因此可以完全下载->这不是一种很好的方法,因为我的数据来自数据库,因此我获得了不同的行数,而且这使应用程序极端缓慢

  1. Changing scrollY = ... in the option list -> it is working but the number of scrollY has to be huge to actually display all data rows so it could be downloaded fully --> not good approach, as my data comes from Database, i obtain different number of rows plus it makes the app extremally slow

使用pageLength选项: pageLength = ...,lengthMenu = c(..,..,..,..)

Using pageLength option: pageLength = ..., lengthMenu=c(..,..,..,..)

但是选择的选项根本不显示...

However the option to choose is not displayed at all...

任何想法我都可以解决这个问题?

Any ideas how i can solve this problem?


  • 我知道 downloadHandler()方法,但是我更愿意通过 DT 完成此操作,因为可用的扩展程序提供了优美而优雅的方式,该方式允许在以下位置下载不同格式的数据:一次,例如pdf,excel,csv和print。

  • I am aware about downloadHandler() approach, however i would prefer to do it through DT as the available Extensions give nice and elegant way, which allows to download the data in different formats at once such as pdf, excel,csv and print.

**我已经看到了相同的问题:

**I have seen already the same question:

下载按钮仅使用Scroller下载DataTables中的145行

,但尚未得到 DT 包裹的含义的答案

but it has not been answered in the meaning of DT package

预先感谢

推荐答案

问题在于,当 server = TRUE 仅将正在显示的数据发送到客户端。设置 server = FALSE 会在客户端中呈现所有DT内容,以便所有数据都在其中。

The issue is that when server=TRUE only the data being displayed is being sent to the client. Setting server=FALSE renders all the DT stuff in the client so all the data is there.

这篇关于按钮:带滚动条的下载按钮仅下载几行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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