CSV File Export Without Loading All Pages
CSV File Export Without Loading All Pages
Dionatan
Posts: 4Questions: 1Answers: 0
I would like to know if there is a way to export a CSV file of everything present in a paginated table using the Buttons extension, but without loading all the pages.
Answers
I'm going to assume you are using server-side processing? Client-side processing will export all rows of the table, hence my assumption.
Based on that, please see this FAQ:
Allan
The processing is client-side. When the user queries a table with, for example, 40,000 records, pagination limits the display to, say, 50 records per page. However, I want the 'Export to .csv' button to export all 40,000 records at once, not just the 50 displayed on the current page.
Please post your Datatables init code. This example shows that by default the export buttons will export all rows in the table when using client side processing. There is something specific to your page that is limiting this.
Kevin
If you could post a link to a test case as well, that would be great.
Thanks,
Allan
You have
serverSide: true,
which enables Server side processing disabling client side processing. The only rows available to export are the rows displayed on the page. See the FAQ Allan linked to for for options.Kevin
A possible solution to export everything while keeping serverSide: True and respecting filters applied in the datatable, it works for the buttons: copy, excel, csv, pdf, print.
{extend: 'csvHtml5', fieldSeparator: ';', extension: '.csv', filename: "Nome da fila", text: "Exportar para .CSV", "action": newexportaction}
Sure, but that's downloading all information to the client-side. So the only thing server-side processing is doing for you is adding network latency. If you know your client is going to export all rows, and you are going to use a client-side export, then use client-side processing.
If you want the chunking benefits of server-side processing and you need CSV export, then you need to do the file building at the server-side.
Allan