1

I have a DataTables with server side processing. On server side I have functions retrieving filters from the ajax request and fetching data from database.

Now I want export data into excel file with filters.

I assume I have to design an excel file creator on server side and send the file through HTTP response.

I would like use already-defined functions to handle export request.

My question is: how can I send DataTables filter as same format as in the ajax request to my server ?

0

1 Answer 1

6

SOLUTION

You can use ajax.params() to get the data submitted by DataTables to the server in the last Ajax request.

Then you can redirect to script that generates Excel file with these parameters using jQuery helper function $.param that converts array into query string.

For example:

window.location = '/getFile.php?' + $.param($('#example').DataTable().ajax.params());

where example is table ID.

NOTES

There is also TableTools extension with Download button but with recent jQuery DataTables 1.10.8 release, TableTools extension is now deprecated.

Sign up to request clarification or add additional context in comments.

3 Comments

@davidkonrad, the link is in the answer, the warning is shown on that page at the top.
@davidkonrad, yes, with 1.10.8 release. See TableTools page: New projects should use Buttons and Select in preference to TableTools. I somewhat complained about documentation removal here but I see where Allan goes with it.
Thank you So much, I am producing my own Excel reports server side and was struggling like mad to get values from ajax.params() this works a treat.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.