footerCallback not working for a few columns

footerCallback not working for a few columns

DingusAmongusDingusAmongus Posts: 7Questions: 3Answers: 0

So I have footerCallback working and showing the totals for some columns, but for other columns that have a colspan header above them, I am getting an error:
0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'toFixed'

In the @section scripts:

    function setFooterCell(row, colNum, total) {
        var TotalCells = row.getElementsByTagName('th');
        TotalCells[colNum].innerHTML = total.toFixed(2);

The error highlights this part of the code:

                        earningsAmountTotal = api
                            .column(16)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);
                            });

                        setFooterCell(row, 5, earningsAmountTotal);

                        deductionsCurrTotal = api
                            .column(18)
                            .data()
                            .reduce(function (a, b) {
                                return intVal(a) + intVal(b);

                                setFooterCell(row, 6, deductionsCurrTotal);

                            });

I'm guessing the issue is that those columns are actually grouped under a colspan header? Please excuse the formatting, I am somewhat new to the ways of the force.

Answers

  • ThomDThomD Posts: 334Questions: 11Answers: 43

    What does the debugger show the value of 'total' parameter as it is passed into setFooterCell.

    In my code, where I'm summing columns, I have this

        CashPaid = api
            .column( 10, { page: 'current'} )
            .data()
            .reduce( function (a, b) {
                return intVal(a) + intVal(b);
            }, 0 ); 
    

    You are missing that 0 parameter.

  • DingusAmongusDingusAmongus Posts: 7Questions: 3Answers: 0

    Another member of the team figured out a fix, but thanks for the help ThomD!

This discussion has been closed.