HaoranLi
HaoranLi

Reputation: 23

How to set "DT::renderDataTable" that I can copy or print all of the table not noly one page?

This is my code, I want copy or print all, but it only print current page, thank you!

library(shiny)
library(DT)
ui <- fluidPage(
  DT::dataTableOutput("tt")
)

server <- function(input, output, session) {
  iris2 = head(iris, 20)
  output$tt <- DT::renderDataTable(
    iris2,
    extensions = 'Buttons', options = list(
      dom = 'Bfrtip',
      buttons = c('copy', 'print')
    )
  )
  
}

shinyApp(ui, server)

Upvotes: 1

Views: 445

Answers (1)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84529

The easiest way is to use the option server = FALSE.

  output$tt <- renderDT({
    datatable(
      iris2,
      extensions = 'Buttons', 
      options = list(
        dom = 'Bfrtip',
        buttons = c('copy', 'print')
      )
    )
  }, server = FALSE)

Upvotes: 2

Related Questions