Error in export to pdf
Error in export to pdf
JonnaCosta
Posts: 1Questions: 0Answers: 0
I have a datatable with more than 300 pages of data and when trying to export in pdf my page is frozen without any type of error. Any solution? Someone handled a lot of information?
when trying export to excel or copy to clipboard it work without problem.
I am using the folowing versions:
DataTables 1.10.18
Buttons for DataTables 1.2.2
Select for DataTables 1.3.0
My code is:
new $.fn.dataTable.Buttons(params.datatable, {
buttons: [{
extend: 'copyHtml5',
className: 'iconIn icon-copy',
exportOptions: {
columns: 'thead th:visible:not(.details-control):not(.buttonsColumns)',
format: {
body: function (data, row, column, node) {
if (data.toString().search('checked') > 0) {
return "si";
}
else if (data.toString().search('checked') < 0 && data.toString().search('input') > 0) {
return "no";
}
else if (data.toString().search("div") > 0) {
return " ";
}
else {
return data;
}
}
}
},
},
{
extend: 'pdfHtml5',
className: 'iconIn icon-pdf',
title: typeof $("#selAirportMaster").val() === "undefined" ? `${document.title} - ${$("#lblAirportMaster").text()}` : `${document.title} - ${$("#selAirportMaster").val()}`,
exportOptions: {
columns: 'thead th:visible:not(.details-control):not(.buttonsColumns)',
format: {
body: function (data, row, column, node) {
if (data.toString().search('checked') > 0) {
return "si";
}
else if (data.toString().search('checked') < 0 && data.toString().search('input') > 0) {
return "no";
}
else if (data.toString().search("div") > 0) {
return " ";
}
else {
return data;
}
}
}
},
customize: function (doc) {
doc.content[1].margin = [60, 0, 50, 0] //left, top, right, bottom CENTRA LA TABLA AL EXPORTAR
},
orientation: 'landscape',
pageSize: 'A4'
},
{
extend: 'excelHtml5',
className: 'iconIn icon-excel',
title: typeof $("#selAirportMaster").val() === "undefined" ? `${document.title} - ${$("#lblAirportMaster").text()}` : `${document.title} - ${$("#selAirportMaster").val()}`,
exportOptions: {
columns: 'thead th:visible:not(.details-control):not(.buttonsColumns)',
format: {
body: function (data, row, column, node) {
if (data.toString().search('checked') > 0) {
return "si";
}
else if (data.toString().search('checked') < 0 && data.toString().search('input') > 0) {
return "no";
}
else if (data.toString().search("div") > 0) {
return " ";
}
else {
return data;
}
}
}
}
}]
}).container().appendTo($('#tableButtons'));
Replies
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin