How to dump table data to a file location on server?
How to dump table data to a file location on server?
Hi all. I have a website which I am rewriting using DataTables. On the old website, I have a piece of code that automatically dumps the content of the table to a .csv file on the server. As I said, the old website does not use DataTables.
I would like to do the same thing on the new website which is using DataTables... i.e. as soon as a page loads, the file is created and dumped to a file location without any interaction from the user. No button pushing, no file location choosing, just a page load.
Any ideas?
Replies
This is not a built in function of Datatables.
My thought would be to use
initComplete
to process the table once loaded. Within initComplete you can parse thejson
object if you usedajax
to load the table. Otherwise you can get the data into an array usingrows().data()
andtoArray()
. Here is a quick example:http://live.datatables.net/xayehela/1/edit
Once you have the data in an array then you can write the code needed to push it to the server.
Kevin