footerCallback
Footer display callback function.
Description
Identical to headerCallback
but for the table footer this function allows you to modify the table footer on every 'draw' event.
Note that if the table does not have a tfoot
element, it this callback will not be fired.
Type
function footerCallback( tfoot, data, start, end, display )
- Parameters:
Name Type Optional 1 tfoot
No tfoot
element of the table's footer2 data
No Full data array of the table. Note that this is in data index order. Use the
display
parameter for the current display order.3 start
No Index for the current display starting point in the display array
4 end
No Index for the current display ending point in the display array
5 display
No Index array to translate the visual position to the full data array
Examples
Alter the content of the footer on callback:
$('#example').dataTable( {
"footerCallback": function( tfoot, data, start, end, display ) {
$(tfoot).find('th').eq(0).html( "Starting index is "+start );
}
} );
Use the API to sum a specific column and output:
$('#example').dataTable( {
"footerCallback": function( tfoot, data, start, end, display ) {
var api = this.api();
$( api.column( 5 ).footer() ).html(
api.column( 5 ).data().reduce( function ( a, b ) {
return a + b;
}, 0 )
);
}
} );
Related
The following options are directly related and may also be useful in your application development.