info.callback
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:
Name Type Optional 1 settings
No DataTables settings object
2 start
No Starting position in data for the draw
3 end
No End position in data for the draw
4 max
No Total number of rows in the table (regardless of filtering)
5 total
No Total number of rows in the data set, after filtering
6 pre
No The string that DataTables has formatted using its own rules
- 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.