You can add "footerCallback" to your .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;
};
total = api
.column( 3 )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
pageTotal = api
.column( 3, { page: 'current'} )
.data()
.reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0 );
$( api.column( 3 ).footer() ).html(
'Total age:'+pageTotal +' ( '+ total +' total)'
);
},
I downloaded jsfiddle
You can change the number of "column (3)" to change the column that you would like to summarize.
Hope this helps :)
source
share