How to dump table data to a file location on server?

How to dump table data to a file location on server?

andy_barberandy_barber Posts: 14Questions: 0Answers: 0

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

  • kthorngrenkthorngren Posts: 21,309Questions: 26Answers: 4,947

    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 the json object if you used ajax to load the table. Otherwise you can get the data into an array using rows().data() and toArray(). 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

This discussion has been closed.