How to export all pages of a table using server-side?
How to export all pages of a table using server-side?
gmpaixao
Posts: 2Questions: 1Answers: 0
Hi everyone,
I was looking for how to export all pages in a table built with server-side, but all the answers didn't works here. If I choose to print came all data in the table, but the others options came only the current page.
Is it possible load the first page, draw the table and in background built the others pages?
My code is:
$(document).ready(function() {
var oTable = $('#DistributorList').dataTable( {
"order": [[ 0, "asc" ]],
"paging": true,
"ordering": true,
"info": true,
"pageLength": 50,
"bLengthChange" : true,
"processing": true,
"serverSide": true,
"pagingType": "full_numbers",
"ajax": $.fn.dataTable.pipeline( {
url: "/ajax/getSalonsList.php",
pages: 100 // number of pages to cache
} ),
"aoColumns": [
{ "bSortable": true, "mDataProp": "SalonName"},
{ "bSortable": true, "mDataProp": "DistributorName" },
{ "bSortable": true, "mDataProp": "DSCName" },
{ "bSortable": true, "mDataProp": "BackBarCredits","sClass": "right" },
{ "bSortable": true, "mDataProp": "MarketingCredits","sClass": "right" },
{ "bSortable": true, "mDataProp": "ERetailCredits","sClass": "right" },
{ "bSortable": true, "mDataProp": "EBackBarCredits","sClass": "right" },
{ "bSortable": true, "mDataProp": "PromotionCredits","sClass": "right" },
{ "bSortable": true, "mDataProp": "EducationCredits","sClass": "right" },
{ "bSortable": false, "mDataProp": "SalonID",
"mRender": function (data) {
var EditLinkText = '<a class="noExport" href="/salon/salon_view.php?salonid=' + data + '&custservmain=1"><img width="20px" title="View Salon Account" src="../img/edit.png"></a>';
return EditLinkText;
} },
],
"dom": '<"clear">T<"clear"><"clear">lfrtip',
"oTableTools": {
"sSwfPath": "/swf/copy_csv_xls_pdf.swf",
"aButtons": [
{
"sExtends": "copy",
"oSelectorOpts": { filter: 'applied', order: 'current' },
"bShowAll": true
},
{
"sExtends": "xls",
"oSelectorOpts": { filter: 'applied', order: 'current' },
"sFileName": "SalonList_<?php echo date("Y-m-d_H-i")?>.xls",
},
{
"sExtends": "csv",
"oSelectorOpts": { filter: 'applied', order: 'current' },
"sFileName": "SalonList_<?php echo date("Y-m-d_H-i")?>.csv",
},
{
"sExtends": "print",
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
]
}
} );
} );
This discussion has been closed.
Answers
I think that datatable not support export all pages. Maybe if you use an ajax request for export all data in a other button?
Is it possible use an ajax request, put the results (json) in a variable, and populate the datatable with the content of this variable? after that I can export, but I think that to draw the datatable will be too slow, am I right?