datatable sum in a
datatable sum in a

Hi,
I am looking for a way to make sum of a column in datatable.net with the value in a span balise and not directly in a td balise. can you help me to modify the code below please ?
my html table is like this :
124 |
i would like to get the 124.
"footerCallback": function(row, data, start, end, display) {
var api = this.api();
api.columns('.no-sort', {
page: 'current'
}).every(function() {
var sum = this
.data()
.reduce(function(a, b) {
var x = parseFloat(a) || 0;
var y = parseFloat(b) || 0;
return x + y;
}, 0);
console.log(sum); //alert(sum);
$(this.footer()).html(sum);
});
}
thanks in advance.
best regards.
This discussion has been closed.
Replies
Change this line to place the
sum
where you would like. In your codethis.footer())
is the selector. Just change it to thespan
elementsid
.Kevin