Don't show foot
Don't show foot
bucanero
Posts: 15Questions: 2Answers: 0
Hi, I need to put totals amounts at column foot. DataTable configuration:
{
retrieve: true,
stateSave: true,
bAutoWidth: false,
stateDuration: -1,
aoColumnDefs:
[
{ bSearchable: false, aTargets: 0 },
{ bSortable: false, aTargets: 0 },
{ sType: "date-eu", aTargets: [1,2] },
{ sType: "sp-string", aTargets: [3,4,5,6,7,8] },
{ render: $.fn.dataTable.render.number( '.', ',', 2, '', '€'), aTargets: 9 },
],
footerCallback: function (row, data, start, end, display)
{
var columna = 9;
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 === 'num' ?
i : 0;
};
// Total over all pages
total = api
.column(columna)
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
// Total over this page
pageTotal = api
.column(columna, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
alert(total + "-" + pageTotal);
// Update footer
$(api.column(columna).footer()).html( pageTotal + ' (Total: 'total +'€)' );
}
}
Alert function displays correct 'total' and 'pageTotal' values, so $(api.column()).footer().html, no works
Thanks.
This discussion has been closed.
Replies
Hi, I've tested it with this:
And it doesn't work either.
Thanks.
Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.
Information on how to create a test page, if you can't provide a link to your own page can be found here.
Thanks,
Allan
I forgot create it at HTML file. (<tfoot>...</tfoot>)
I turned red with shame and apologize for my cluelessness. ;-))
Thanks for all.
No worries :-). Thanks for posting back!
Allan