Total sum of all columns in the footer.

Total sum of all columns in the footer.

iDataTablesiDataTables Posts: 4Questions: 0Answers: 0
edited March 2014 in General
I trying to display the sum of each column in the footer. Here is my javascript. iTotal is the array containing the sums of all columns. I can't seem to display the sum in the column. The Footer would just have one tag in the nCells.innerHTML. Any idea how I can do that? Thanks

[code]function setupDataTables(json) {
var settings = {
"aaData": json.aaData,
"aoColumns": json.aoColumns,
"aaSorting": [[0, "asc"]],
"bDestroy": true,
"bRetrieve": true,
"bJQueryUI": true,
"bScrollInfinite": true,
"bScrollCollapse": true,
"bDeferRender": true,
"iDisplayLength": 100,
"sScrollY": "1000px",
"fnFooterCallback": function (nFoot, aaData, iStart, iEnd, aiDisplay) {

var iTotal = [];
for (var i = 0; i < aaData[i].length - 2; i++) {
iTotal.push(0);
for (var k = 0; k < aaData.length; k++) {
iTotal[i] += parseInt(aaData[k][i + 2], 10);
}
}
var nCells = nFoot.getElementsByTagName('tfoot');
for (var l = 0; l < iTotal.length; l++) {
nCells[l].innerHTML = '' + iTotal[l] + ',';
}

}

}
oTable = $('#compTable').dataTable(settings);
}[/code]
This discussion has been closed.