Get the whole state of current serverside data to export
Get the whole state of current serverside data to export
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
See this FAQ.
Kevin
either: 1. Use a server-side process to create the files to download
what does that mean ?
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