Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82676

Print option in jquery datatable--would like to print the final total of a column in the footer

$
0
0

Currently only the first page total is printed in the footer.
code used
footer:true,
exportOptions: {

                           modifier: {
                               order: 'index', // 'current', 'applied','index', 'original'
                               page: 'all', // 'all', 'current'
                               search: 'none' // 'none', 'applied', 'removed'
                           },
                           columns: [0, 1, 2, 3, 4]

}
footer call back is

                footerCallback: function( tfoot, data, start, end, display ) {
                    var api = this.api();
                    var intVal = function (i) {
                        return typeof i === 'string' ?
                            i.replace(/[\$,]/g, '') * 1 :
                            typeof i === 'number' ?
                            i : 0;
                    };
                    total = api
           .column(4)
           .data()
           .reduce(function (a, b) {
               return intVal(a) + intVal(b);
           }, 0)

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

                    $(api.column(4).footer()).html(
                             pageTotal + ' (' + total + ' total)'
                       );

}

the values displayed in the page are correct. But on print option only the first page total is displayed in the footer.


Viewing all articles
Browse latest Browse all 82676

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>