Footer Content calculated in fnFooterCallback not exported
Footer Content calculated in fnFooterCallback not exported
lisah_weducom
Posts: 0Questions: 0Answers: 0
I have a DataTable, with TableTools, where I am generating column totals in the footer using the fnFooterCallback function. While the footer content display as expected in the HTML version of the DataTables, the export to PDF (or CSV) does not include the footer data as generated in the callback.
DataTables debug bookmarklet: atamaz
DataTables 1.9.4
TableTools 2.1.4
A very basic example, with the minimal amount of code to reproduce the issue: Demonstration: http://dev-3.staging.wedu.com/ttools_test.php
my initialization and fnFooterCallback:
[code]
$(document).ready( function () {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay )
{
$(nFoot).append('Grand Totals:');
var tot = 0;
for (var i=0; i
DataTables debug bookmarklet: atamaz
DataTables 1.9.4
TableTools 2.1.4
A very basic example, with the minimal amount of code to reproduce the issue: Demonstration: http://dev-3.staging.wedu.com/ttools_test.php
my initialization and fnFooterCallback:
[code]
$(document).ready( function () {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"fnFooterCallback": function( nFoot, aData, iStart, iEnd, aiDisplay )
{
$(nFoot).append('Grand Totals:');
var tot = 0;
for (var i=0; i
This discussion has been closed.
Replies
So the two options are:
1. Modify TableTools to pull in the data dynamically from the created cells
2. Modify your initialisation to put the cells in initially and then update their contents rather than recreating them on each draw.
Allan
i mean that tr in the body contains 2 td but tr at the footer contains one td
I had tried to add Total of debit column at my datatable and export to csv worked
this is the structure of my datatable
Type
Name
الاسم
Qty
Unit
Price
Date
Debit
Credit
Loading data from server
<%--
Total Debit
--%>
Total Debit
00.00
and the function that calculates the total debit is
"fnFooterCallback": function (nRow, aaData, iStart, iEnd, aiDisplay) {
var total_debit = 0;
for (var i = 0; i < aaData.length; i++) {
total_debit += parseFloat(aaData[i]['Debit']);
}
var nCells = nRow.getElementsByTagName('th');
nCells[8].innerHTML = total_debit ;
}
the commented part at the section didn't work at the export but when i put the same structure as body it worked
I hope this will work with you