I am using datatables. In addition to the regular table set up I am using datatables to add
Row Groups - Outlined here
Column Totals - Using Footer Callbacled Outlined here
I have a working Demo here http://jsfiddle.net/c5UXe/
Everything is working fine except my totals are being calculated 1 column off to the right (as you can easily see from demo) I am pretty sure the reason is because of the way groups works and is displayed.
I would like to display the totals under the correct column. i.e. shift all totals 1 column left to line up correctly.
The code used uses the first <td> in the row to use as the group name so for example
<td>Joe Hammer</td> is used as a group name.
This is the code I am using to calculate the totals
"fnFooterCallback": function (nRow, aasData, iStart, iEnd, aiDisplay) {
var columnas = [1, 2, 3, 4, 5, 6, 7]; //the columns you wish to add
for (var j in columnas) {
var columnaActual = columnas[j];
var total = 0;
for (var i = iStart; i < iEnd; i++) {
total = total + parseFloat(aasData[aiDisplay[i]][columnaActual]);
}
$($(nRow).children().get(columnaActual)).html(total);
} // end