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

New - initisalisation: iDeferLoading can now also be an array allowing the developer to specify the number of records before and after filtering for the information display - 7936

This commit is contained in:
Allan Jardine 2012-03-03 07:34:11 +00:00
parent fc730e17f3
commit cc42c49ec3
3 changed files with 27 additions and 6 deletions

View File

@ -6320,8 +6320,9 @@
if ( oInit.iDeferLoading !== null )
{
oSettings.bDeferLoading = true;
oSettings._iRecordsTotal = oInit.iDeferLoading;
oSettings._iRecordsDisplay = oInit.iDeferLoading;
var tmp = $.isArray( oInit.iDeferLoading );
oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
}
if ( oInit.aaData !== null )

View File

@ -197,8 +197,9 @@ if ( oInit.bStateSave )
if ( oInit.iDeferLoading !== null )
{
oSettings.bDeferLoading = true;
oSettings._iRecordsTotal = oInit.iDeferLoading;
oSettings._iRecordsDisplay = oInit.iDeferLoading;
var tmp = $.isArray( oInit.iDeferLoading );
oSettings._iRecordsDisplay = tmp ? oInit.iDeferLoading[0] : oInit.iDeferLoading;
oSettings._iRecordsTotal = tmp ? oInit.iDeferLoading[1] : oInit.iDeferLoading;
}
if ( oInit.aaData !== null )

View File

@ -1154,12 +1154,18 @@ DataTable.defaults = {
* will be applied to it), thus saving on an XHR at load time. iDeferLoading
* is used to indicate that deferred loading is required, but it is also used
* to tell DataTables how many records there are in the full table (allowing
* the information element and pagination to be displayed correctly).
* @type int
* the information element and pagination to be displayed correctly). In the case
* where a filtering is applied to the table on initial load, this can be
* indicated by giving the parameter as an array, where the first element is
* the number of records available after filtering and the second element is the
* number of records without filtering (allowing the table information element
* to be shown correctly).
* @type int | array
* @default null
* @dtopt Options
*
* @example
* // 57 records available in the table, no filtering applied
* $(document).ready(function() {
* $('#example').dataTable( {
* "bServerSide": true,
@ -1167,6 +1173,19 @@ DataTable.defaults = {
* "iDeferLoading": 57
* } );
* } );
*
* @example
* // 57 records after filtering, 100 without filtering (an initial filter applied)
* $(document).ready(function() {
* $('#example').dataTable( {
* "bServerSide": true,
* "sAjaxSource": "scripts/server_processing.php",
* "iDeferLoading": [ 57, 100 ],
* "oSearch": {
* "sSearch": "my_filter"
* }
* } );
* } );
*/
"iDeferLoading": null,