Get the whole state of current serverside data to export

Get the whole state of current serverside data to export

_mercury_mercury Posts: 12Questions: 3Answers: 0

I have a table that loads data by ajax serverside
And I also enable export excel
the issue is how to get the current data of all the filtered/seraced rows to export ?

$('#guest_scan-products').DataTable({
lengthMenu: [
[10, 25, 50, -1],
[10, 25, 50, "All"]
],
language: language,
serverSide: true,
processing: true,
ajax: '/api/g/scan-products',
columns: productCols.filter(col => col.data !== 'cost'),
order: [
[0, 'desc']
],
dom: 'lBfrtip',
orderCellsTop: true,
fixedHeader: false,
initComplete,
buttons: [{
extend: 'excel',
titleAttr: 'Export Excel',
"oSelectorOpts": {
filter: 'applied',
order: 'current'
},
exportOptions: {
modifier: {
page: 'all'
},
format: formatExport
}
}],
});

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    See this FAQ.

    Kevin

  • _mercury_mercury Posts: 12Questions: 3Answers: 0

    either: 1. Use a server-side process to create the files to download
    what does that mean ?

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951
    Answer ✓

    Use an Excel library that is compatible with your server side environment to export the data directly from the data source. You could create a custom button, like this example that sends the filter information to the server via ajax and your server script will use the Excel library to export the relevant data.

    Kevin

Sign In or Register to comment.