I need help for sum column

I need help for sum column

fanmasfanmas Posts: 1Questions: 1Answers: 0
edited January 2022 in Free community support

I have

"columns": [
            { "data": "date"},
            { "data": null, "defaultContent": ''},
            { "data": "all_sum"},           
            { "data": null, "defaultContent": ''},
            { "data": null, "defaultContent": ''},
            { "data": "acc_sum" },
            { "data": "acc_man_sum" },
            { "data": "profit" },
            { "data": null, "defaultContent": '' }

        ],

And render

return '<a href="javascript:;" data-id="'+id+'" data-type="'+my_type+'" id="profit_doc" class="ajax_link">'+row.prod_base_sum+'</a>'

And column sum

var intVal = function ( i ) {
                    return typeof i === 'string' ?
                        i.replace(/[\$,]/g, '')*1 :
                        typeof i === 'number' ?
                            i : 0;
                };
                
                isum1 = api
                    .column( 3 )
                    .data()
                    .reduce( function (a, b) {
                        return intVal(a) + intVal(b);
                    } );

But sum = 0
I want sum row.prod_base_sum
Other columns working reduce function
How i sum render column?

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kthorngrenkthorngren Posts: 21,351Questions: 26Answers: 4,955

    See if this thread helps.

    Kevin

Sign In or Register to comment.