I’m trying to add a button to download the content of my DataTable as CSV. I want all the data available, not only the currently visible data in the table (columns can be hidden and the table is paginated).
Here’s the code for my table:
DT::renderDataTable({
# .../...
},
extensions = c('Buttons'),
options = list(
lengthMenu = list(c(10, 100, 500, -1), c(10, 100, 500, "Tout")),
pageLength = 100,
searching = FALSE,
language = list(url = "datatable.frFR.json"),
dom = "<'row'<'col-sm-4 info'i><'col-sm-4 actions'B><'col-sm-4 filter'l>><'row'<'col-sm-12'tr>><'row'<'col-sm-5'i><'col-sm-7'p>>",
buttons = list(
list(extend = 'colvis', text = 'Colonnes affichées', columns = c(1:9)),
list(extend = 'csv', text = 'Télécharger CSV', exportOptions = list(modifier = list(order = 'original', page = 'all')))
),
columnDefs = list(
list(targets = c(3, 5, 9), visible = FALSE)
)
))
neither the order = 'original'
nor the page = 'all'
seem to be working (the current order is used and only the current number of rows is exported). What am I doing wrong?