Display count of calculated row in pdfexport

Display count of calculated row in pdfexport

crush123crush123 Posts: 417Questions: 126Answers: 18
edited July 2016 in Buttons

I have a json sourced table with ticket quantity and price columns, and a subtotal column which multiplies the 2 values together

The column is generated like so...

{ data: null,
  render: function ( data, type, row ) {
  subtotal = Math.round( row.tblorderdetails.DetailPrice * row.tblorderdetails.DetailQuantity );
  return subtotal;
}
}

And I have a footerCallback to display the sum on the table footer

How can I output the sum of this calculated column to a pdf export, as it doesn;t export the footer?

I can output the quantity ok

var tcount = dt.column( 3 ).data().reduce( function (a, b) {return parseInt(a) + parseInt(b);   } );
return tcount+' tickets';

but as the data in the column is null, i get NAn output if I try and do the same with the calculated column

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,508Questions: 1Answers: 10,471 Site admin
    Answer ✓

    dt.column( 3 ).data()

    but

    data: null,

    You need to use cells().render() to get the rendered data (rather than column().data() to get data which doesn't exist). If you do a search for cells().render() you'll find a few other threads on this topic if you would like more details.

    Allan

  • crush123crush123 Posts: 417Questions: 126Answers: 18

    Thanks Allan

    Needed a few attempts to get the syntax, but looks like i got there...

    var subtotal = table.cells( null, 4 ).render( 'display' );
    //console.log(subtotal);
    var gtotal = subtotal.reduce( function (a, b) {return parseInt(a) + parseInt(b);    } );
    
This discussion has been closed.