Datatable row grouping subtotal based on value inside td span tag
Datatable row grouping subtotal based on value inside td span tag
![crazyx7](https://secure.gravatar.com/avatar/fc727c418980882d938b8685ad4e8516/?default=https%3A%2F%2Fvanillicon.com%2Ffc727c418980882d938b8685ad4e8516_200.png&rating=g&size=120)
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