You would need to use "exportOptions" and "customize".
On this page you'll find a comment from zebral at the bottom. From the customize function you could do an ajax call passing the "csv" variable. Eventually you should be able to empty that variable so nothing gets downloaded. But there might be a different way for this. https://datatables.net/reference/button/csv
In "exportOptions" return true for the columns you want to keep and false for the columns you don't want to include.
Ok Thanks will try that and get back with results.
My initial thought was to use the ”action” parameter but I didnt find any way to prevent the download.
Answers
You would need to use "exportOptions" and "customize".
On this page you'll find a comment from zebral at the bottom. From the customize function you could do an ajax call passing the "csv" variable. Eventually you should be able to empty that variable so nothing gets downloaded. But there might be a different way for this.
https://datatables.net/reference/button/csv
In "exportOptions" return true for the columns you want to keep and false for the columns you don't want to include.
Ok Thanks will try that and get back with results.
My initial thought was to use the ”action” parameter but I didnt find any way to prevent the download.
Hi again,
Im using the following code, which successfully get the csv content without downloading.
It is saved into 'data' variable as an object.
I want to send this to a php script.
Can I use DataTables API to create the csv file (not downloading) and send it as a file through ajax, like FormData.
Or should I send the js object and use own php script to create csv?
I don't know to be honest. I would send whatever is easier and causes less work for you.
I solved this by creating the CSV serverside with PHP, from the POST:ed js array.