{hero}

info.callback

Since: DataTables 2.0

Information display callback.

Description

This option can be used to customise the text shown by the info feature, including replacing the text generated entirely or customising it as needed. That could also be used to be notified of a change in the paging of the table, although the info and page events would be better suited in most cases.

The legacy infoCallback option is an alias to this option for all information displays shown for the table.

Type

function infoCallback( settings, start, end, max, total, pre )

Parameters:
Returns:

The string to be displayed in the information element.

Examples

Customise the display with a callback function:

new DataTable('#myTable', {
	layout: {
		bottomStart: {
			info: {
				callback: function (s, start, end, max, total, result) {
					return `${start} to ${end} rows are shown, of ${max}`;
				}
			}
		}
	}
});

Use the API in the callback to show page count:

new DataTable('#myTable', {
	layout: {
		bottomStart: {
			info: {
				callback: function (s, start, end, max, total, result) {
					let api = this.api();
					let pageInfo = api.page.info();

					return 'Page ' + (pageInfo.page + 1) + ' of ' + pageInfo.pages;
				}
			}
		}
	}
});

Related

The following options are directly related and may also be useful in your application development.