mirror of
https://github.com/DataTables/DataTables.git
synced 2025-01-30 23:52:11 +01:00
New: Defered loading feature for server-side processing. With this feature enabled (controlled by the new initialisation parameter iDeferLoading) DataTables will not make a request to the server for the first page draw - rather it will use the data already on the page (no sorting etc will be applied to it). iDeferLoading is used to indicate that defered 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). The intention of this feature is to improve the progressive enhancement foundation and accessibility of DataTables.
This commit is contained in:
parent
83db797888
commit
01ffda313f
29
media/js/jquery.dataTables.js
vendored
29
media/js/jquery.dataTables.js
vendored
@ -1159,6 +1159,14 @@
|
||||
*/
|
||||
this.nTableWrapper = null;
|
||||
|
||||
/*
|
||||
* Variable: bDeferLoading
|
||||
* Purpose: Indicate if when using server-side processing the loading of data
|
||||
* should be defered until the second draw
|
||||
* Scope: jQuery.dataTable.classSettings
|
||||
*/
|
||||
this.bDeferLoading = false;
|
||||
|
||||
/*
|
||||
* Variable: bInitialised
|
||||
* Purpose: Indicate if all required information has been read in
|
||||
@ -2711,7 +2719,7 @@
|
||||
* Add the data object for the whole table - storing the tr node. Note - no point in getting
|
||||
* DOM based data if we are going to go and replace it with Ajax source data.
|
||||
*/
|
||||
if ( oSettings.sAjaxSource === null )
|
||||
if ( oSettings.bDeferLoading || oSettings.sAjaxSource === null )
|
||||
{
|
||||
nTrs = oSettings.nTBody.childNodes;
|
||||
for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
|
||||
@ -3045,16 +3053,20 @@
|
||||
_fnCalculateEnd( oSettings );
|
||||
}
|
||||
|
||||
/* If we are dealing with Ajax - do it here */
|
||||
if ( !oSettings.bDestroying && oSettings.oFeatures.bServerSide &&
|
||||
!_fnAjaxUpdate( oSettings ) )
|
||||
/* Server-side processing draw intercept */
|
||||
if ( oSettings.bDeferLoading )
|
||||
{
|
||||
return;
|
||||
oSettings.bDeferLoading = false;
|
||||
oSettings.iDraw++;
|
||||
}
|
||||
else if ( !oSettings.oFeatures.bServerSide )
|
||||
{
|
||||
oSettings.iDraw++;
|
||||
}
|
||||
else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( oSettings.aiDisplay.length !== 0 )
|
||||
{
|
||||
@ -6586,6 +6598,13 @@
|
||||
"sName": "state_save"
|
||||
} );
|
||||
}
|
||||
|
||||
if ( typeof oInit.iDeferLoading != 'undefined' )
|
||||
{
|
||||
oSettings.bDeferLoading = true;
|
||||
oSettings._iRecordsTotal = oInit.iDeferLoading;
|
||||
oSettings._iRecordsDisplay = oInit.iDeferLoading;
|
||||
}
|
||||
|
||||
if ( typeof oInit.aaData != 'undefined' )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user