Having problem in row grouping with calculation.
Having problem in row grouping with calculation.
ManiDhoni
Posts: 10Questions: 0Answers: 0
Hi!
Having an issue with the rowgroup feature. Trying to add the values of a calculated column but keep getting NaN in the grouping:
"columns": [
{
"render": function (data, type, full, meta) {
return '<td><div><span>' + full.order_date + '</span></div></td>'
}
},
{ "data": "facility_name" },
{ "data": "ResidentName" },
{ "data": "order_id" },
{
"render": function (data, type, full, meta) {
return parseInt(full.Value.toFixed(2))
}, className: "Total",
},
],
order: [[3, 'asc']],
rowGroup: {
startRender: null,
endRender: function ( rows, group ) {
var totalspend = rows
.data()
.pluck(4)
.reduce( function (a, b) {
return a + b;
}, 0);
return $('<tr/>')
.append( '<td></td><td></td><td></td><td>Total Spend</td>' )
.append( '<td>'+totalspend.toFixed(2)+'</td>' )
},
dataSrc: "order_id"
},
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This discussion has been closed.
Replies
Can anyone please help me to resolve this issue.
See Colin's example from this thread.
Kevin
Hi @kthorngren this example shows only for grouping name. can u please tell me how to calculate grouping value and bind
Hi @colin and @allen could u please help me to resolve this issue.
That example shows how to use
cell().render()
to get the rendered value of a cell. Sounds like that is what you are asking for. If you need help with an example then please start by building a test case with an example of your data so we can provide a specific solution.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
You can update Colin's example if you like, just post the new URL.
Kevin