How to export all data with buttons?

How to export all data with buttons?

Daniel2Daniel2 Posts: 1Questions: 1Answers: 0

Right now datatables is only exporting the visible rows ( I am using server-side processing w/ paging). How can I make the buttons export/print all the data (not just the visible rows).

Thanks,
Dan

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    This seems to be a popular question lately..

    Basically, the serverSide only pulls and renders the rows that will be visible at that time, right? So how will it know to export rows that it hasn't even pulled or rendered.

    @kwein1 said:

    I solved my similar problem by simply adding a -1 option to the dropdown of the paging options. That allows me to select all records (it takes a while to display, true) so then the Excel export button exports all records, since they're all displayed. I had to modify a LIMIT statement in my DB grab in my PHP so it would do the right thing when it received a -1.

    But if you think about it, that totally voids the purpose of serverSide

    My reply to both of those threads, and still my recommended answer:

    , if you're using the serverSide option, then overall, you're playing around with more rows than you would want to export.. I would think it would be best to play around with the lengthMenu, giving the viewers limits of how much they can export, then allow them to filter for the relevant data they want to export via search... EG: If they want to export all rows containing "Some Data", then set the page length to the highest you would let it go (100, 200?), then filter for "Some Data", and export that.

This discussion has been closed.