Total input inside datatable my code
Total input inside datatable my code
danielandres.feo
Posts: 5Questions: 0Answers: 1
var table = $('#sedes-focalizacion-table').DataTable({
'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 filtered indicate col index
$.each([6, 8, 15, 10], function(index, value) {
pageTotal = 0;
total = 0;
var columnas = api
.column(value, {
page: 'current'
})
.nodes();
var columnas_total = api
.column(value)
.nodes();
$.each(columnas_total, function(index, value) {
var a = $(value).find('input[type=text]').val();
pageTotal = pageTotal + intVal(a);
});
$.each(columnas, function(index, value) {
var a = $(value).find('input[type=text]').val();
total = total + intVal(a);
});
// Update footer
$(api.column(value).footer()).html(
'Filtro:' + pageTotal + ' ( ' + total + ' Total)'
);
});
}
});
This discussion has been closed.
Replies
works !!!