PDF and Excel buttons with server side processing
PDF and Excel buttons with server side processing
Hi all,
I am using server side processing, but would still like to use the flash app for download PDF/Excel functionality.
Now it seems that when I press the print button the datatables does a call to the server side with -1 for the result length, so it can display the whole result set. However, it seem pressing PDF or Excel button does not do such call, so pressing these buttons only display the currently visible results.
I have read some threads about this and the solution seems to be "stop using the flash app". However, I really would like to keep the flash app, so does anyone know workaroud to get it working with the server side?
Regards,
Olli
I am using server side processing, but would still like to use the flash app for download PDF/Excel functionality.
Now it seems that when I press the print button the datatables does a call to the server side with -1 for the result length, so it can display the whole result set. However, it seem pressing PDF or Excel button does not do such call, so pressing these buttons only display the currently visible results.
I have read some threads about this and the solution seems to be "stop using the flash app". However, I really would like to keep the flash app, so does anyone know workaroud to get it working with the server side?
Regards,
Olli
This discussion has been closed.
Replies
In server side, if you want all data and not the currently visible results, you have to use "download" from TableTools :
[code]
TableTools.BUTTONS.download = {
"sAction": "text",
"sTag": "default",
"sFieldBoundary": "",
"sFieldSeperator": "\t",
"sNewLine": "
",
"sToolTip": "",
"sButtonClass": "DTTT_button_text",
"sButtonClassHover": "DTTT_button_text_hover",
"sButtonText": "Download",
"mColumns": "all",
"bHeader": true,
"bFooter": true,
"sDiv": "",
"fnMouseover": null,
"fnMouseout": null,
"fnClick": function( nButton, oConfig ) {
var oParams = this.s.dt.oApi._fnAjaxParameters( this.s.dt );
var iframe = document.createElement('iframe');
iframe.style.height = "0px";
iframe.style.width = "0px";
iframe.src = oConfig.sUrl+"?"+$.param(oParams);
document.body.appendChild( iframe );
},
"fnSelect": null,
"fnComplete": null,
"fnInit": null
};
$(document).ready(function() {
// Affichage du tableau avec le détail des entrées
$('#idTAB).dataTable({
"bProcessing": true,
"bServerSide": true,
"sPaginationType": "full_numbers",
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [{
"sExtends": "download",
"sButtonText": "EXCEL",
"sUrl": "generate_excel.php"
},{
"sExtends": "download",
"sButtonText": "PDF",
"sUrl": "generate_pdf.php"
}, "print"]
},
"sAjaxSource": "serverside.php",
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "json",
"cache": false
} );
}
})
[/code]
You have to create your own generate_excel.php and generate_pdf.php.
I don't know if that the issue that you hope, but in server side, for all data, or data with filter, I think it's just this issue that's work.
Magali
To my mind it just doesn't make sense to use server-side processing, then need to load the full data set into the client for the Excel export. You'd be much better off using client-side processing from the start.
Allan
Will go ahead implementing a server side csv generator then :)
Olli