Footer Sums
Footer Sums
dobulet302
Posts: 38Questions: 0Answers: 0
I am trying to display the sum of each column in the footer, I am using this code
[code]
"fnFooterCallback": function(nRow, aasData, iStart, iEnd, aiDisplay ) {
//delete the footers
$($(nRow).children()).remove();
//recreate the footers
for(var i=0;i
[code]
"fnFooterCallback": function(nRow, aasData, iStart, iEnd, aiDisplay ) {
//delete the footers
$($(nRow).children()).remove();
//recreate the footers
for(var i=0;i
This discussion has been closed.
Replies
If you "console.log( parseInt(aasData[aiDisplay[i]][5]) )" in the for loop, what output do you get on the console?
Allan
[code]
"fnFooterCallback": function (nRow, aasData, iStart, iEnd, aiDisplay ) {
$($(nRow).children()).remove();
for(var i=0;i
What Allan is finding funny is you're expecting to see a floating point number (e.g. NNNNN.nnnnn) after having told the code to make it an integer using parseInt. Integers are WHOLE numbers (i.e. no decimal point or figures below it).
Hint: try parseFloat?
ruzz
ruzz
[code]
for(var i=iStart;i
Allan
it shows NaN (34 times) then the rest of the data....nothing else.
Allan
[code]
"fnFooterCallback": function (nRow, aasData, iStart, iEnd, aiDisplay ) {
$($(nRow).children()).remove();
for(var i=0;i
I'm not sure what you mean by comma and decimal - do you mean a comma for a thousands separator? From the above code you are only going to get integers. In which case you could use the built in number formatter in DataTables:
[code]
$($(nRow).children().get(columnaActual)).html(
this.fnFormatNumber( total ) );
);
[/code]
It won't cope with floats though. For that, have a look on Google - there are loads of number formatters available for Javascript.
Allan