Change Format of Sum within Footer
Change Format of Sum within Footer

Hi all,
I am using the following code to calculate the total of a column:
footerCallback: function ( row, data, start, end, display ) {
var api = this.api(), data;
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, '.');
};
total = api
.column(3, { search: 'applied'} )
.data()
.reduce( function (a, b) {
return numberWithCommas(intVal(a) + intVal(b));
}, 0 );
$( api.column( 3 ).footer() ).html(
'Summe: ' + total
);
It works perfectly fine besides the fact, that numbers are displayed like this:
1.000.20
Whereelse it should be:
1.000,20
So the thousand seperator should be a point (like it is now), where the decimal seperator needs to be a comma.
Can anyone help me to achieve this?
Thanks for your time!!!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
data tables has a method to render numbers like this: