How do I add a row for totals and one for percentages?
How do I add a row for totals and one for percentages?
MrJasinski
Posts: 1Questions: 1Answers: 0
in General
Hi,
I have this code below which works as intended i.e. it adds a total row for all but the first column
"footerCallback": function (row, data, start, end, display) {
var api = this.api(), data;
var colNumber =Array.from(Array(45+1).keys()).slice(1);
var intVal = function (i) {
return typeof i === 'string' ? i * 1 : typeof i === 'number' ? i : 0;
};
for (i = 0; i < colNumber.length; i++) {
var colNo = colNumber[i];
var total = api.column(colNo).data().reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
$(api.column(colNo).footer()).html(total);
}
}
The last column is a total for that row which means the last column in the footer is the total number (let's call this X)
What I now need to do is also add a row below the total row showing the percentage against the value X
Any suggestions?
This discussion has been closed.
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin