Server side processing: export all rows
Server side processing: export all rows
bliksempie
Posts: 17Questions: 4Answers: 0
Please can you advise how I would export all content when using server side processing to CSV? Using the examples work only for local data, not ajax processing. Here is what I am using:
buttons: [{
extend: "collection",
className: "exportButton",
text: "Export",
buttons: [{
extend: "csv",
text: "Export as CSV",
exportOptions: {
modifier: {
page: "all",
search: "none"
}
}
}]
}]
Is there something specific I must do to make it work with server side processing? I can't find anything in the docs, but it may be because I am not sure how to search for this particular case.
Thanks!
This question has accepted answers - jump to:
Answers
To elaborate: the above example, using local data, exports all data, but with server side processing, it exports only the current page.
The Datatables export buttons support exporting data at the client. With Server Side Processing enabled the only data at the client is the current page. See this FAQ for more details.
Kevin
Hi Kevin,
Thanks - that is a pity - but hoping there may be a work-around.
My data table is only showing data from one database table, but when I export the data, I want to join two database tables together, matching all the filters chosen, including all the extended columns, but ignoring pagination, and then export to file (CSV). I can do the server side processing to handle this, but not sure how to link this to the export button then. Is this possible?
I was thinking:
Since it looks like I can do alerts here, I should be able to do an Ajax call in here, right?
Sorry - some clarification on my request: Trying it now, but not sure how to pass the selected filters, POST data or whatever is needed to filter results, through to the action.
You can use
search()
to get the search value of the global search input and, if doing column searches, you can usecolumns().search()
to get the values of the column searches. You can pass these in the jQuery ajax() request of the custom button.Kevin
Just to directly answer this question:
Yes - it is just a Javascript function. You can do whatever you want in there.
There is a download button plug-in which might be of some interest - it will open a URL in an iframe which, with the correct mime type from the server, will trigger a download.
Allan
Thank you very much. I appreciate your help!