infoCallback
Table summary information display callback.
Description
The information element can be used to convey information about the current state of the table. Although the internationalisation options presented by DataTables are quite capable of dealing with most customisations, there may be times where you wish to customise the string further. This callback allows you to do exactly that.
Please note that if the info
option is disabled in the initialisation, this callback function is not fired.
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
Show start to end indexes in the information element:
$('#example').dataTable( {
"infoCallback": function( settings, start, end, max, total, pre ) {
return start +" to "+ end;
}
} );
Use the API in the callback to show page count:
$('#example').dataTable( {
"infoCallback": function( settings, start, end, max, total, pre ) {
var api = this.api();
var 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.