1
0
mirror of https://github.com/DataTables/DataTables.git synced 2024-12-01 13:24:10 +01:00

New: Pagination language options (i18n) have _PAGE_ and _PAGES_ options

- Based on the discussion in forum thread 16938 DataTables now has the
  ability to use _PAGE_ and _PAGES_ in addition to the exisiting
  _START_, _END_, _MAX_ and _TOTAL_ options in the information language
  strings. This allows the developer to show paging information rather
  than record based information in the information element.
This commit is contained in:
Allan Jardine 2013-08-20 15:01:25 +01:00
parent 425eb38c5b
commit e6840bd2cf
2 changed files with 24 additions and 10 deletions

View File

@ -1 +1 @@
ad25f79e7614164e30d030d7bcc295ccd8833f7c 04be76a50f2e29d12369faaee03bacb29b92592a

View File

@ -2583,14 +2583,19 @@
// When infinite scrolling, we are always starting at 1. _iDisplayStart is used only // When infinite scrolling, we are always starting at 1. _iDisplayStart is used only
// internally // internally
var var
start = settings.oScroll.bInfinite ? 1 : settings._iDisplayStart+1, formatter = settings.fnFormatNumber,
formatter = settings.fnFormatNumber; start = settings.oScroll.bInfinite ? 1 : settings._iDisplayStart+1,
len = settings._iDisplayLength,
vis = settings.fnRecordsDisplay(),
all = len === -1;
return str. return str.
replace(/_START_/g, formatter.call( settings, start ) ). replace(/_START_/g, formatter.call( settings, start ) ).
replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ). replace(/_END_/g, formatter.call( settings, settings.fnDisplayEnd() ) ).
replace(/_TOTAL_/g, formatter.call( settings, settings.fnRecordsDisplay() ) ). replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ).
replace(/_MAX_/g, formatter.call( settings, settings.fnRecordsTotal() ) ); replace(/_TOTAL_/g, formatter.call( settings, vis ) ).
replace(/_PAGE_/g, formatter.call( settings, all ? 1 : Math.ceil( start / len ) ) ).
replace(/_PAGES_/g, formatter.call( settings, all ? 1 : Math.ceil( vis / len ) ) );
} }
@ -10500,10 +10505,19 @@
/** /**
* This string gives information to the end user about the information that * This string gives information to the end user about the information
* is current on display on the page. The _START_, _END_ and _TOTAL_ * that is current on display on the page. The following tokens can be
* variables are all dynamically replaced as the table display updates, and * used in the string and will be dynamically replaced as the table
* can be freely moved or removed as the language requirements change. * display updates. This tokens can be placed anywhere in the string, or
* removed as needed by the language requires:
*
* * `\_START\_` - Display index of the first record on the current page
* * `\_END\_` - Display index of the last record on the current page
* * `\_TOTAL\_` - Number of records in the table after filtering
* * `\_MAX\_` - Number of records in the table without filtering
* * `\_PAGE\_` - Current page number
* * `\_PAGES\_` - Total number of pages of data in the table
*
* @type string * @type string
* @default Showing _START_ to _END_ of _TOTAL_ entries * @default Showing _START_ to _END_ of _TOTAL_ entries
* *
@ -10514,7 +10528,7 @@
* $(document).ready( function() { * $(document).ready( function() {
* $('#example').dataTable( { * $('#example').dataTable( {
* "language": { * "language": {
* "info": "Got a total of _TOTAL_ entries to show (_START_ to _END_)" * "info": "Showing page _PAGE_ of _PAGES_"
* } * }
* } ); * } );
* } ); * } );