how i can add total for another column ?
how i can add total for another column ?
keremgenisel
Posts: 2Questions: 1Answers: 0
$(document).ready(function () {
$('#myTable').DataTable({
responsive: true,
"language": {
"url": "//cdn.datatables.net/plug-ins/1.10.16/i18n/Turkish.json"
},
"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
total = api
.column(8,)
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
// Total over this page
pageTotal = api
.column(8, { page: 'current' })
.data()
.reduce(function (a, b) {
return intVal(a) + intVal(b);
}, 0);
// Update footer
$(api.column(8).footer()).html(
'₺' + formatMoney(pageTotal, 0, '.', ',') + ' ( ₺' + formatMoney(total, 0, '.', ',') + ' Genel Toplam)'
);
}
});
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Duplicate the code for
// Total over all pages
and// Total over this page
, change the column number and assign to different variables.Kevin
thanks for your answer and im junior , ı have to duplicate // update footer ? and this is my tfoot code:
<tfoot>
<tr>
<th colspan="3" style="text-align:right;color:orange">Total Salary:</th>
<th colspan="3"></th>
<th colspan="3" style="text-align:right;color:red">Total Form:</th>
<th colspan="3"></th>
</tr>
</tfoot>
its true ?
Kevin was referring to your JS - if you look at the sections with the comments he pointed out, that's what you need to duplicate.
C