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.
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).
Sample code:
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
))
}
)
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')
)
)
I have tried different approaches:
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
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()
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:
Download button downloads only 145 rows in DataTables with Scroller
but it has not been answered in the meaning of DT
package
Thanks in advance
It is indeed server = TRUE
that does the trick.
Here is the code since some people like me might put the argument in the wrong place.
library("shiny")
library("DT")
shinyApp(
ui = fluidPage(DT::dataTableOutput('tbl')),
server = function(input, output) {
output$tbl = DT::renderDataTable(server = FALSE,{
DT::datatable(iris,
extensions=c("Buttons",'Scroller'),
options = list(dom = 'Bfrtip',
buttons = c('copy', 'csv',
'excel', 'pdf',
'print'),
scrollY = 50,
scroller = TRUE)
)
})
}
)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With