How to use Colvis with fnFooterCallback?

How to use Colvis with fnFooterCallback?

KyvuKyvu Posts: 11Questions: 0Answers: 0
edited March 2013 in General
Hello to all,

I try to use fnFooterCallback in order to calculate the sum of some columns. It is ok and pretty cool! But unfortunalty, my Javascript fails when I want to add the ColVis function on my table.

My HTML:

[code]


Part numberDesc 1Desc 2QuantityWeightHeightMisc


201-1704desc 1desc 21614misc
6Y-4898desc 1desc 2216misc
6Y-5685desc 1desc 23211misc
4I-7472desc 1desc 24612misc
124-3296desc 1desc 25613misc
141-9655desc 1desc 26214misc
166-3729desc 1desc 2736misc
207-3658desc 1desc 2866misc
255-8095desc 1desc 2964misc
125-4403desc 1desc 21034misc


Total


[/code]

My JS:

[code]
$("#mydatatable").dataTable({
"aaSorting": [],
"bSort": true,
"bPaginate": true,
"bAutoWidth": false,
"sDom": 'C<"clear">lfrtip',
"oColVis": {"buttonText": "Hide", "aiExclude": [0, 1, 2]},
"fnFooterCallback": function(nRow, aaData, iStart, iEnd, aiDisplay) {
var arraytotaux = [];
arraytotaux[3] = 0;
arraytotaux[4] = 0;
arraytotaux[5] = 0;
for (var i = 0; i < aiDisplay.length; i++) {
arraytotaux[3] += aaData[aiDisplay[i]][3] * 1;
arraytotaux[4] += aaData[aiDisplay[i]][4] * 1;
arraytotaux[5] += aaData[aiDisplay[i]][5] * 1;
}
var nCells = nRow.getElementsByTagName("th");
nCells[3].innerHTML = arraytotaux[3];
nCells[4].innerHTML = arraytotaux[4];
nCells[5].innerHTML = arraytotaux[5];
}
})
[/code]

Problem starts when I try to hide or show columns, with this kind of messages:

TypeError: nCells[5] is undefined
nCells[5].innerHTML = arraytotaux[5];

Could you please help?

Thanks.

Regards.

Kyvu
This discussion has been closed.