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

New: Allow state loading to be cancelled from the aoStateLoadParams callbacks by returning false (matches the capabilities of the old state loading methods)

This commit is contained in:
Allan Jardine 2012-01-02 10:19:19 +00:00
parent 1bdbe86da2
commit f702ac5648
3 changed files with 36 additions and 4 deletions

View File

@ -4277,8 +4277,14 @@
return;
}
/* Allow custom and plug-in manipulation functions to alter the saved data set */
_fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] );
/* Allow custom and plug-in manipulation functions to alter the saved data set and
* cancelling of loading by returning false
*/
var abStateLoad = _fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] );
if ( $.inArray( false, abStateLoad ) !== -1 )
{
return;
}
/* Store the saved state so it might be accessed at any time */
oSettings.oLoadedState = $.extend( true, {}, oData );
@ -8343,6 +8349,16 @@
* oData.oFilter.sSearch = "";
* } );
* } );
*
* @example
* // Disallow state loading by returning false
* $(document).ready(function() {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateLoadParams": function (oSettings, oData) {
* return false;
* } );
* } );
*/
"fnStateLoadParams": null,

View File

@ -55,8 +55,14 @@ function _fnLoadState ( oSettings, oInit )
return;
}
/* Allow custom and plug-in manipulation functions to alter the saved data set */
_fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] );
/* Allow custom and plug-in manipulation functions to alter the saved data set and
* cancelling of loading by returning false
*/
var abStateLoad = _fnCallbackFire( oSettings, 'aoStateLoadParams', 'stateLoadParams', [oSettings, oData] );
if ( $.inArray( false, abStateLoad ) !== -1 )
{
return;
}
/* Store the saved state so it might be accessed at any time */
oSettings.oLoadedState = $.extend( true, {}, oData );

View File

@ -988,6 +988,16 @@ DataTable.defaults = {
* oData.oFilter.sSearch = "";
* } );
* } );
*
* @example
* // Disallow state loading by returning false
* $(document).ready(function() {
* $('#example').dataTable( {
* "bStateSave": true,
* "fnStateLoadParams": function (oSettings, oData) {
* return false;
* } );
* } );
*/
"fnStateLoadParams": null,