Closed TychaK closed 2 years ago
Documentation for that is not here since everything can be done on the jquery datatables.net side. See their documentation, maybe specifically here - https://datatables.net/plug-ins/api/sum()
Adding this callback in options object does not work why.
"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
var total = api.column( 3, { search: 'applied'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Update footer
console.log(api);
$( api.column( 3 ).footer() ).html(total);
},
But testing in jsfiddle works very much fine. I've added
also, The above lines should replace the 3rd footer column with with the total value, But it doesnot work but while using console.log(total) it gives the total correctly. Seems the problem is in vue component side of the datatable. Help meStale issue.
There's no available documentation on how to add the footer callback with sums.