Having problem in row grouping with calculation.

Having problem in row grouping with calculation.

ManiDhoniManiDhoni Posts: 10Questions: 0Answers: 0
edited March 2021 in Free community support

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.

Replies

This discussion has been closed.