{hero}

footerCallback

Since: DataTables 1.10

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( tr, data, start, end, display )

Parameters:

Examples

Alter the content of the footer on callback:

new DataTable('#myTable', {
	footerCallback: function (tr, data, start, end, display) {
		$(tr)
			.find('th')
			.eq(0)
			.html('Starting index is ' + start);
	}
});

Use the API to sum a specific column and output:

new DataTable('#myTable', {
	footerCallback: function (tr, 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.