1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-02-18 16:54:14 +01:00

Dev update: Remove the 'row' event. On experimenting with CellCreated I've found that I'm getting around 4'500 triggers / sec with Safari 5.1, which really isn't close to fast enough (about two orders of magnitude out from what I would like) which means that a table with 2000 rows and 9 columns would see an additional overhead of about 4 seconds on initialisation - ouch!!! As such I've removed the 'row' event here and it would seriously impact larger tables. events are still extremely useful, however, I would suggest that plug-ins should use the callback arrays rather than events since it is much faster. These arrays might be developed further into DataTables' own triggering methods in future. Something to to be aware of certainly going into 1.10.

This commit is contained in:
Allan Jardine 2011-12-27 19:46:43 +00:00
parent 5a2d4f8782
commit 4808f0edd7
5 changed files with 29 additions and 41 deletions

View File

@ -1041,6 +1041,7 @@
}
}
}
}
@ -1349,7 +1350,7 @@
}
/* Row callback functions - might want to manipule the row */
_fnCallbackFire( oSettings, 'aoRowCallback', 'row',
_fnCallbackFire( oSettings, 'aoRowCallback', null,
[nRow, oSettings.aoData[ oSettings.aiDisplay[j] ]._aData, iRowCount, j] );
anRows.push( nRow );
@ -4719,10 +4720,12 @@
/**
* Fire callback functions and trigger events. Note that the loop over the callback
* array store is done backwards!
* array store is done backwards! Further note that you do not want to fire off triggers
* in time sensitive applications (for example cell creation) as its slow.
* @param {object} oSettings dataTables settings object
* @param {string} sStore Name of the array storeage for the callbacks in oSettings
* @param {string} sTrigger Name of the jQuery customer event to trigger
* @param {string} sTrigger Name of the jQuery custom event to trigger. If null no trigger
* is fired
* @param {array) aArgs Array of arguments to pass to the callback function / trigger
* @memberof DataTable#oApi
*/
@ -4736,7 +4739,10 @@
aRet.push( aoStore[i].fn.apply( oSettings.oInstance, aArgs ) );
}
if ( sTrigger !== null )
{
$(oSettings.oInstance).trigger(sTrigger, aArgs);
}
return aRet;
}
@ -11158,18 +11164,6 @@
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
/**
* Row draw event, fired when a row is included in a draw
* @name DataTable#row
* @event
* @param {event} e jQuery event object
* @param {node} nRow "TR" element for the current row
* @param {array} aData Raw data array for this row
* @param {int} iDisplayIndex The display index for the current table draw
* @param {int} iDisplayIndexFull The index of the data in the full list of
* rows (after filtering)
*/
/**
* DataTables initialisation complete event, fired when the table is fully drawn,
* including Ajax data loaded, if Ajax data is required.

View File

@ -178,18 +178,6 @@
* @param {object} o DataTables settings object {@link DataTable.models.oSettings}
*/
/**
* Row draw event, fired when a row is included in a draw
* @name DataTable#row
* @event
* @param {event} e jQuery event object
* @param {node} nRow "TR" element for the current row
* @param {array} aData Raw data array for this row
* @param {int} iDisplayIndex The display index for the current table draw
* @param {int} iDisplayIndexFull The index of the data in the full list of
* rows (after filtering)
*/
/**
* DataTables initialisation complete event, fired when the table is fully drawn,
* including Ajax data loaded, if Ajax data is required.

View File

@ -74,6 +74,7 @@ function _fnCreateTr ( oSettings, iRow )
}
}
}
}
@ -382,7 +383,7 @@ function _fnDraw( oSettings )
}
/* Row callback functions - might want to manipule the row */
_fnCallbackFire( oSettings, 'aoRowCallback', 'row',
_fnCallbackFire( oSettings, 'aoRowCallback', null,
[nRow, oSettings.aoData[ oSettings.aiDisplay[j] ]._aData, iRowCount, j] );
anRows.push( nRow );

View File

@ -234,10 +234,12 @@ function _fnCallbackReg( oSettings, sStore, fn, sName )
/**
* Fire callback functions and trigger events. Note that the loop over the callback
* array store is done backwards!
* array store is done backwards! Further note that you do not want to fire off triggers
* in time sensitive applications (for example cell creation) as its slow.
* @param {object} oSettings dataTables settings object
* @param {string} sStore Name of the array storeage for the callbacks in oSettings
* @param {string} sTrigger Name of the jQuery customer event to trigger
* @param {string} sTrigger Name of the jQuery custom event to trigger. If null no trigger
* is fired
* @param {array) aArgs Array of arguments to pass to the callback function / trigger
* @memberof DataTable#oApi
*/
@ -251,7 +253,10 @@ function _fnCallbackFire( oSettings, sStore, sTrigger, aArgs )
aRet.push( aoStore[i].fn.apply( oSettings.oInstance, aArgs ) );
}
if ( sTrigger !== null )
{
$(oSettings.oInstance).trigger(sTrigger, aArgs);
}
return aRet;
}

View File

@ -29,19 +29,19 @@
//if ( typeof console != 'undefined' ) {
// console.profile();
//}
//for ( var i=0 ; i<1 ; i++ )
//{
// var oTable = $('#example').dataTable({"bDestroy": true});
//}
for ( var i=0 ; i<10 ; i++ )
{
var oTable = $('#example').dataTable({"bDestroy": true});
}
//if ( typeof console != 'undefined' ) {
// console.profileEnd();
//}
oTable.fnSort( [[ 1, 'asc' ]] );
oTable.fnSort( [[ 1, 'asc' ]] );
oTable.fnSort( [[ 2, 'asc' ]] );
oTable.fnSort( [[ 1, 'asc' ]] );
oTable.fnSort( [[ 2, 'asc' ]] );
//oTable.fnSort( [[ 1, 'asc' ]] );
//oTable.fnSort( [[ 1, 'asc' ]] );
//oTable.fnSort( [[ 2, 'asc' ]] );
//oTable.fnSort( [[ 1, 'asc' ]] );
//oTable.fnSort( [[ 2, 'asc' ]] );
var iEnd = new Date().getTime();
document.getElementById('output').innerHTML = "Test took "+(iEnd-iStart)+" mS";