how to add or subtract from a column depending on another column colour text in FooterCallback

how to add or subtract from a column depending on another column colour text in FooterCallback

UlotharUlothar Posts: 1Questions: 1Answers: 0
edited February 26 in Free community support

Hello, I have this situation where I want to have the footer of column 4 SUM the values when the Column 3 is red texted but to subtract when the Column 3 is blue texted.

            footerCallback: function (row, data, start, end, display) {
                var api = this.api();

                // Remove the formatting to get integer data for summation
                var intVal = function (i) {
                    return typeof i === 'string' ? i.replace(/[\$,]/g, '') * 1 : typeof i === 'number' ? i : 0;
                };
                //Σύνολο Τιμών

                var totalA = 0;

                api.cells(null, 3, {

                page: 'current'
                })
                .nodes()
                .each(function(n) {


                        if($(n)
                        .hasClass('text-danger')) {


                        //totalA += intVal(api.row(counter).data()['amount']);
                        //totalA += intVal($(n)
                                //.text());
                }
                })

                 $(api.column(4).footer()).html('€' + totalA);

thank you very much

Answers

Sign In or Register to comment.