Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

Trying to get the number of rows so I can calculate an average for the footer using the footerCallba

$
0
0

I'm sure this is very simple but I cannot find it...

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

    var theColumnTotal = api
        .column( 4 )
        .data()
        .reduce( function (a, b) {
            if(isNaN(a)){
                return '';
            } else {
                a = parseFloat(a);
            }
            if(isNaN(b)){ 
                return '';
            } else {
                b = parseFloat(b);
            }
            return (a + b).toFixed(2);
        }, 0 );

    // Update footer
    $( api.column( 4 ).footer() ).html(
        theColumnTotal / [NEED ROW COUNT HERE]
    );
}

Let me know if there is any further info needed, thanks!


Viewing all articles
Browse latest Browse all 2364