Add Multiple total to Datatable Dynamic (Añadiendo multiples totales a datatable Dinamicamente)
Add Multiple total to Datatable Dynamic (Añadiendo multiples totales a datatable Dinamicamente)
danielandres.feo
Posts: 5Questions: 0Answers: 1
Tabla_colegio = $('#tabla_reporte_colegios').DataTable({
'footerCallback': function(row, data, start, end, display) {
var api = this.api(),
data;
var intVal = function(i) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '') * 1 :
typeof i === 'number' ?
i : 0;
};
// Columns array to totalize
$.each([1, 2, 3], function(index, value) {
total = api
.column(value)
.data()
.reduce(function(a, b) {
return intVal(a) + intVal(b);
}, 0);
// Total over this page
pageTotal = api
.column(value, {
page: 'current'
})
.data()
.reduce(function(a, b) {
return intVal(a) + intVal(b);
}, 0);
// Update footer
$(api.column(value).footer()).html(
'Filtro:' + pageTotal + ' ( ' + total + ' Total)'
);
});
}
});
This discussion has been closed.