Datatable row grouping subtotal based on value inside td span tag
Datatable row grouping subtotal based on value inside td span tag
crazyx7
Posts: 1Questions: 1Answers: 0
I have tried this, but it only work when the value displayed inside td without any tag.
rowGroup: {
startRender:function(rows,group){
return group +' ( '+rows.count()+' )';
},
endRender: function ( rows, group ) {
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
var sub = rows
.data()
.pluck(1)
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0);
return $('<tr/>')
.append( '<td>Sub-total for '+group+'</td>' )
.append( '<td>'+sub+'</td>' )
.append('<tr></tr>')
},
dataSrc: 0
},
How can i sum up the value of the column's row when the value is inside the span tag?
This discussion has been closed.
Answers
Hi @crazyx7 ,
You just need to get inside the element, so change
to be
as in this example here,
Cheers,
Colin