Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35273

api.column().data() call on rendered column

$
0
0

So I'm pretty sure my issue is that I'm using the column().data() function on a column that the data is set to null. But when I set it to anything else and then render it, I get data that I don't want.

 columns: [
            { data: "tbl_types.type_desc" },
            { data: "tbl_pexpenses.description" },
            { data: "tbl_pexpenses.cost" },
            { data: "tbl_pexpenses.quantity" },
            { data:  null, 
                    render: function ( data, type, row ) {
                return (data.tbl_pexpenses.cost*data.tbl_pexpenses.quantity);
            } }
        ],
footerCallback: function ( row, data, start, end, display ) {
            var api = this.api(), data;
 
            // 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;
            };
 
            // Total over all pages
            data = api.column( 4 ).data();
            total = data.length ?
                data.reduce( function (a, b) {
                        return intVal(a) + intVal(b);
                } ) :
                0;
 
            // Update footer
            $( api.column( 4 ).footer() ).html(
                '$'+ total
            );
        }

Is there any way to make the column data: data.tbl_pexpenses.cost*data.tbl_pexpenses.quantity <<< this?


Viewing all articles
Browse latest Browse all 35273

Trending Articles