can print page sum(page total) for each page in datatable ?
can print page sum(page total) for each page in datatable ?
kirish28
Posts: 1Questions: 1Answers: 0
"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 : isNaN(parseInt(i)) ? 0 : parseInt(i);
};
api.columns('.sum', { page: 'current'}).every( function () {
var sum = this
.data()
.reduce( function (a, b) {
//console.log(intVal($(a).text()));
//console.log(intVal($(b).text()));
var rex = /(<([^>]+)>)/ig;
var aa = a.toString().replace(rex , "");
var bb = b.toString().replace(rex , "");
return intVal(aa) + intVal(bb);
}, 0 );
this.footer().innerHTML = sum.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
} );
}
i am using to footerCallback method to get page total it's fine.
but when i print the table, can not get page total for each page.
in print view get first page sum value to all other pages .
This discussion has been closed.
Answers
The print view will print the footer as shown in the DataTable at the time of printing. It will not attempt to calculate different values for the pages that are printed I'm afraid.
Allan