Exporting datatable to Excel

Exporting datatable to Excel

jstuardojstuardo Posts: 104Questions: 41Answers: 0

Hello,

I need to program an export functionality and even when I am including "Buttons" plugin, I am not using it in the toolbar because I am using custom buttons. I need only to use exportData functionality of the plugin, however, when I do something like:

var table = $('#myTable').DataTable();

var data = table.buttons.exportData();

I got the error:

Page:542 Uncaught TypeError: Cannot read property 'exportData' of undefined
    at HTMLButtonElement.<anonymous> (Page:542)
    at HTMLButtonElement.dispatch (jquery-3.5.0.js:5429)
    at HTMLButtonElement.elemData.handle (jquery-3.5.0.js:5233)

If that way does not work, is there a way I can retrieve the posted data to a remote server (this is an ajax source)?

My idea, in this case, is to call the same URL of the Ajax parameter with the same posted data but adding a new parameter to allow exporting.

Any advice will be appreciated

Thanks

Jaime

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.