I just noticed that datatable
from DT
library does not export all rows in the underlying dataset. It exports only visible rows. In the following reproducible example, it returns only 25 rows which are visible by default.
I wonder if there is any workaround to fix this.
library(shiny)
library(DT)
## Data table output format
data_output <- function(df) {
DT::datatable(df, rownames= FALSE, options = list( dom = 'Bfrtip', buttons = c('excel','pdf','print','colvis'), pageLength = 25, initComplete = DT::JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'background-color': '#369BE9', 'color': '#fff'});",
"}") ),
extensions = c('Buttons','FixedColumns'))
}
## Shiny UI
ui <- basicPage(
h2("The mtcars data"),
DT::dataTableOutput("mytable")
)
## Shiny Server
server <- function(input, output) {
output$mytable = DT::renderDataTable({
data_output(iris)
})
}
shinyApp(ui, server)