Error sum total - Page 2

Error sum total

2»

Answers

  • allanallan Posts: 63,262Questions: 1Answers: 10,424 Site admin

    I really didn't want to just write the code for you, but you don't appear to be doing any debugging between posts to understand what is actually happening with the code. I'd rather you learn how to debug and write the code that you need for your specific use case, but we are just going around in circles.

    The first thing to do for your latest code is to update the intVal as it doesn't extract the integer for the data in your example:

    var intVal = function (i) {
        return typeof i === 'string'
            ? i.replace(/[^\d]/g, '') * 1
            : typeof i === 'number'
                ? i
                : 0;
    };
    

    Then use something like:

    pageTotal = api
        .rows({page: 'current'}) 
        .data()
        .reduce(
            (a, b) => {
                if (b[3].includes('Falta Paga')) {
                    return a;
                }
                else {
                    return a + intVal(b[3]);
                }
            },
            0
        );
    

    What is happening there is that a condition is used to ignore any row which has the text Falta Paga in column index 3. I don't know if I've got that logic correct for your requirement - update that line as needed. I've also used rows().data() as I would strongly suggest you split out the flag for still to pay / payment received into a different column. Use a renderer if you need to combine multiple data points into a single column.

    Allan

  • FHUSAINFHUSAIN Posts: 2Questions: 0Answers: 0

    I am using DATATABLES I have problem when send to printer the total of column is wrong what appear is total of column when I browse repot on screen,, any solution for this problem.
    thanks

    fathi ibrahi,
    abuhusiain2002@hotmail.com

  • allanallan Posts: 63,262Questions: 1Answers: 10,424 Site admin

    Per my multiple e-mail replies to you on the subject, please link to a test case on the issue so I can help to debug it.

    Allan

Sign In or Register to comment.