subtotals and totals in the foot, in different rows
subtotals and totals in the foot, in different rows
bucanero
Posts: 15Questions: 2Answers: 0
Hi, in this example:
https://datatables.net/examples/advanced_init/footer_callback.html
Is it possible to put the totals and subtotals in different rows?
In my case, there are three columns (without taxes, taxes and taxes included) and I need subtotals per page, and totals. Here it's, only with totals (without subtotals):
footerCallback:
function (row, data, start, end, display)
{
var api = this.api(), data;
var subtotalSenseIva = api.column(4).data().sum();
var subtotalIva = api.column(6).data().sum();
var subtotalAmbIva = api.column(7).data().sum();
subtotalSenseIva = $.fn.dataTable.render.number('.', ',', 2, '', '€').display(subtotalSenseIva);
subtotalIva = $.fn.dataTable.render.number('.', ',', 2, '', '€').display(subtotalIva);
subtotalAmbIva = $.fn.dataTable.render.number('.', ',', 2, '', '€').display(subtotalAmbIva);
$(api.column(4).footer()).html(subtotalSenseIva);
$(api.column(6).footer()).html(subtotalIva);
$(api.column(7).footer()).html(subtotalAmbIva);
},
<tfoot>
<tr>
<th></th>
<th></th>
<th></th>
<th style='text-align:right'>SUBTOTALS</th>
<th style='text-align:right'></th>
<th></th>
<th style='text-align:right'></th>
<th style='text-align:right'></th>
</tr>
</foot>
I've repeated <tr></tr> in foot structure, and I put, in js file, this:
var totalSenseIva = api.column(4, {page:'current'}).data().sum();
totalSenseIva = $.fn.dataTable.render.number('.', ',', 2, '', '€').display(totalSenseIva);
$(api.column(4).footer()).html(totalSenseIva);
but it doesn't work.
Thanks
This discussion has been closed.