1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-01-18 11:52:11 +01:00

Fixed: fnInitComplete was being called too early for server-side processing. It is now called after the first draw is complete, like the other data sources.

This commit is contained in:
Allan Jardine 2010-09-07 21:37:56 +01:00
parent 4154332be2
commit 2c4def9353
4 changed files with 60 additions and 9 deletions

View File

@ -2262,7 +2262,7 @@
_fnProcessingDisplay( oSettings, false );
/* Run the init callback if there is one */
/* Run the init callback if there is one - done here for ajax source for json obj */
if ( typeof oSettings.fnInitComplete == 'function' )
{
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings, json );
@ -2271,12 +2271,6 @@
return;
}
/* Run the init callback if there is one */
if ( typeof oSettings.fnInitComplete == 'function' )
{
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings );
}
if ( !oSettings.oFeatures.bServerSide )
{
_fnProcessingDisplay( oSettings, false );
@ -3041,6 +3035,12 @@
_fnAjustColumnSizing( oSettings );
}
if ( typeof oSettings.fnInitComplete == 'function' &&
(oSettings.oFeatures.bServerSide || oSettings.sAjaxSource === null) )
{
oSettings.fnInitComplete.call( oSettings.oInstance, oSettings );
}
/* Set an absolute width for the table such that pagination doesn't
* cause the table to resize - disabled for now.
*/

View File

@ -73,6 +73,22 @@ $(document).ready( function () {
);
oTest.fnWaitTest(
"10 rows in the table on complete",
function () {
oSession.fnRestore();
mPass = 0;
$('#example').dataTable( {
"fnInitComplete": function ( ) {
mPass = $('#example tbody tr').length;
}
} );
},
function () { return mPass == 10; }
);
oTest.fnComplete();
} );

View File

@ -19,7 +19,7 @@ $(document).ready( function () {
oTest.fnWaitTest(
"One argument passed (for Ajax!)",
"Two arguments passed (for Ajax!)",
function () {
oSession.fnRestore();
@ -78,6 +78,23 @@ $(document).ready( function () {
);
oTest.fnWaitTest(
"10 rows in the table on complete",
function () {
oSession.fnRestore();
mPass = 0;
$('#example').dataTable( {
"sAjaxSource": "../../../examples/examples_support/json_source.txt",
"fnInitComplete": function ( ) {
mPass = $('#example tbody tr').length;
}
} );
},
function () { return mPass == 10; }
);
oTest.fnComplete();
} );

View File

@ -82,6 +82,24 @@ $(document).ready( function () {
);
oTest.fnWaitTest(
"10 rows in the table on complete",
function () {
oSession.fnRestore();
mPass = 0;
$('#example').dataTable( {
"bServerSide": true,
"sAjaxSource": "../../../examples/examples_support/server_processing.php",
"fnInitComplete": function ( ) {
mPass = $('#example tbody tr').length;
}
} );
},
function () { return mPass == 10; }
);
oTest.fnComplete();
} );