Avoiding "$" in column sum

Avoiding "$" in column sum

giulichajarigiulichajari Posts: 19Questions: 8Answers: 0

I have the next code for showing the total below the table:

           "footerCallback": function ( row, data, start, end, display ) {

        total = this.api()
            .column(4)//numero de columna a sumar
            //.column(1, {page: 'current'})//para sumar solo la pagina actual
            .data()
            .reduce(function (a, b) {
                return parseFloat(a) + parseFloat(b);
            }, 0 );
        console.log(total);
        $(this.api().column(4).footer()).html("ss"+total);

     },

but i have currency formatting the colum:

         return "$" + row.importe;

What can i do to sume the numbers, if i use parseFloat it don'tn funciton because of the symbol.

Answers

  • colincolin Posts: 15,142Questions: 1Answers: 2,586

    Hi @giulichajari ,

    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: 20,269Questions: 26Answers: 4,765
    edited October 2019

    Take a look at the footercallback example to see how to do this.

    Kevin

This discussion has been closed.