Footer not printing in PDF or Excel
Footer not printing in PDF or Excel
Hello,
PDF/Excel export not printing Updated Footer based on fnFooterCallback. The Data in PDF is from page load.
Thanks for the help.
[code]
oTable = $('#dtTable').dataTable({
"sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"oTableTools": {
"aButtons": [
{
"sButtonClass" : "btn-primary",
"sExtends": "copy",
'mColumns':'visible',
"fnCellRender": function(sValue, iColumn, nTr, iDataIndex) {
return '"' + sValue.replace(/
|/g, "\n") + '"';
}
},
{
"sButtonClass" : "btn-primary",
"sExtends": "print",
'mColumns':'visible',
},
{
"sButtonClass" : "btn-primary",
"sExtends": "pdf",
"sTitle": "Report for First Name Last Name",
"sPdfOrientation": "landscape",
'mColumns':'visible',
},
{
"sButtonClass" : "btn-primary",
"sExtends": "xls",
"sTitle": "Report for First Name Last Name",
"fnCellRender": function(sValue, iColumn, nTr, iDataIndex) {
return '"' + sValue.replace(/
|/g, "\n") + '"';
}
}
]
},
//"sScrollY": "200px",
//"bPaginate": false,
"iDisplayLength" : 20,
"bProcessing": true,
"bAutoWidth": false,
"bServerSide": false,
"sAjaxSource": dataUrl,
"fnServerData": function(sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "Get",
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
var oTable = $('#dtTable').dataTable();
var col;
//find the status
for (var i = 0; i < oTable.fnSettings().aoColumns.length; i++) {
if (oTable.fnSettings().aoColumns[i].sTitle == "Status") {
col = i;
break;
}
}
if (aData[col] == "Disapproved") {
$('td:eq(' + col + ')', nRow).parent().addClass("error");
}
return nRow;
},
"fnFooterCallback": function(nRow, aaData, iStart, iEnd, aiDisplay) {
var oTable = $('#dtTable').dataTable();
var col;
//find the total col
for (var i = 0; i < oTable.fnSettings().aoColumns.length; i++) {
if (oTable.fnSettings().aoColumns[i].sTitle == "Amount") {
col = i;
break;
}
}
var iTotal = 0;
//add the total up
for (var i = iStart; i < iEnd; i++) {
iTotal += Number(aaData[aiDisplay[i]][col].substring(1,aaData[aiDisplay[i]][col].length).replace(/[^0-9\.]+/g,""));
}
if (!isNaN(iTotal)) {
nCells = $('.TfootDataTable');
//'Total$ ' +iTotal+ '';
nCells.html('Total' + FormatToCurrency(iTotal) + '');
}
}
});
[/code]
PDF/Excel export not printing Updated Footer based on fnFooterCallback. The Data in PDF is from page load.
Thanks for the help.
[code]
oTable = $('#dtTable').dataTable({
"sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"oTableTools": {
"aButtons": [
{
"sButtonClass" : "btn-primary",
"sExtends": "copy",
'mColumns':'visible',
"fnCellRender": function(sValue, iColumn, nTr, iDataIndex) {
return '"' + sValue.replace(/
|/g, "\n") + '"';
}
},
{
"sButtonClass" : "btn-primary",
"sExtends": "print",
'mColumns':'visible',
},
{
"sButtonClass" : "btn-primary",
"sExtends": "pdf",
"sTitle": "Report for First Name Last Name",
"sPdfOrientation": "landscape",
'mColumns':'visible',
},
{
"sButtonClass" : "btn-primary",
"sExtends": "xls",
"sTitle": "Report for First Name Last Name",
"fnCellRender": function(sValue, iColumn, nTr, iDataIndex) {
return '"' + sValue.replace(/
|/g, "\n") + '"';
}
}
]
},
//"sScrollY": "200px",
//"bPaginate": false,
"iDisplayLength" : 20,
"bProcessing": true,
"bAutoWidth": false,
"bServerSide": false,
"sAjaxSource": dataUrl,
"fnServerData": function(sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "Get",
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"fnRowCallback": function(nRow, aData, iDisplayIndex) {
var oTable = $('#dtTable').dataTable();
var col;
//find the status
for (var i = 0; i < oTable.fnSettings().aoColumns.length; i++) {
if (oTable.fnSettings().aoColumns[i].sTitle == "Status") {
col = i;
break;
}
}
if (aData[col] == "Disapproved") {
$('td:eq(' + col + ')', nRow).parent().addClass("error");
}
return nRow;
},
"fnFooterCallback": function(nRow, aaData, iStart, iEnd, aiDisplay) {
var oTable = $('#dtTable').dataTable();
var col;
//find the total col
for (var i = 0; i < oTable.fnSettings().aoColumns.length; i++) {
if (oTable.fnSettings().aoColumns[i].sTitle == "Amount") {
col = i;
break;
}
}
var iTotal = 0;
//add the total up
for (var i = iStart; i < iEnd; i++) {
iTotal += Number(aaData[aiDisplay[i]][col].substring(1,aaData[aiDisplay[i]][col].length).replace(/[^0-9\.]+/g,""));
}
if (!isNaN(iTotal)) {
nCells = $('.TfootDataTable');
//'Total$ ' +iTotal+ '';
nCells.html('Total' + FormatToCurrency(iTotal) + '');
}
}
});
[/code]
This discussion has been closed.
Replies