Can I show page info instead of record info for sInfo?
Can I show page info instead of record info for sInfo?
Simon79
Posts: 8Questions: 1Answers: 0
Instead of displaying something like the following for sInfo:
"Showing 1 to 10 of 15 entries"
is it possible to just show something like:
"Showing page 1 of 2"
and exclude the filtering details, etc? All I want is for the current set of filtered data the page I'm on and the total number of pages.
"Showing 1 to 10 of 15 entries"
is it possible to just show something like:
"Showing page 1 of 2"
and exclude the filtering details, etc? All I want is for the current set of filtered data the page I'm on and the total number of pages.
This discussion has been closed.
Replies
You could use fnInfoCallback in 1.9- and the plug-in fnPagingInfo to achieve this, but I'll put it straight into the core for 1.10. I'll try to do this later on today.
Allan
I'll have a look at the fnInfoCallback options.
thanks!
FYI for anyone who needs something like this, just add fnPagingInfo:
[code]
/* API method to get paging information */
$.fn.dataTableExt.oApi.fnPagingInfo = function(oSettings) {
return {
"iStart": oSettings._iDisplayStart,
"iEnd": oSettings.fnDisplayEnd(),
"iLength": oSettings._iDisplayLength,
"iTotal": oSettings.fnRecordsTotal(),
"iFilteredTotal": oSettings.fnRecordsDisplay(),
"iPage": oSettings._iDisplayLength === -1 ?
0 : Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
"iTotalPages": oSettings._iDisplayLength === -1 ?
0 : Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
};
};
[/code]
then use fnInfoCallback:
[code]
'fnInfoCallback': function (oSettings) {
var pagingInfo = $.fn.dataTableExt.oApi.fnPagingInfo(oSettings);
return 'Showing page ' + (pagingInfo.iPage + 1) + ' of ' + pagingInfo.iTotalPages;
}
[/code]
Commit here: https://github.com/DataTables/DataTablesSrc/commit/04be76a
And if you are feeling brave, the built source here: https://github.com/DataTables/DataTables/blob/1_10_wip/media/js/jquery.dataTables.js
This means that in 1.10 you can do:
[code]
$('#example').dataTable( {
language: {
info: "Showing page _PAGE_ of _PAGES_"
}
} );
[/code]
Nice suggestion - thanks for this :-)
Allan