Use number render on total values in footer
Use number render on total values in footer
martin1223345
Posts: 84Questions: 23Answers: 0
Hopefully my last question.. (sorry for al the questions)
I managed to get a total row in my footer that workes perfectly. I have tried to apply the folowing number render but no mather where i place it nothing works. Does anyone know how to aply this to the total output values?
$.fn.dataTable.render.number( '.', '.', 0 )
The total footer function where i need the output to be 5.000.000 instead of 5000000:
"footerCallback": function ( row, data, start, end, display ) {
var api = this.api(), data;
// converting to interger to find total
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
// computing column Total of the complete result
var bulletTotal = api
.column( 3,{page:'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
var leadTotal = api
.column( 7, {page:'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
var cashTotal = api
.column( 8, {page:'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer by showing the total with the reference of the column index
$( api.column( 0 ).footer() ).html('Total');
$( api.column( 3 ).footer() ).html(bulletTotal);
$( api.column( 7 ).footer() ).html(leadTotal);
$( api.column( 8 ).footer() ).html(cashTotal);
},
This discussion has been closed.
Answers
Use the number renderer the same as we discussed in your other thread.
Kevin
I tried. But i cant seem to get it done. I dont know where to place it. All places i tried where no succes..
Tried it like this after some thinking about your answer. Also no succes. So what has to be rendererd?
Got it ! Thanks !
The code: