{hero}

stateSaveParams

Since: DataTables 1.10

State save event - fired when saving table state information.

Description

The stateSaveParams event is the event compliment of the stateSaveParams initialisation option. As with the callback, the event is fired when the table has changed state a new state save is required. For the format of the data that is stored, please refer to the stateSaveCallback documentation.

This event allows modification of the state saving object prior to actually doing the save, including addition or other state properties (for plug-ins) or modification of a DataTables core property.

The stateSaveParams event is fired at the same point as stateSaveCallback (technically the callback fires before the event, but they occur sequentially and thus either can be used to achieve the same effect).

Please note that, as with all DataTables emitted events, the event object has a DataTables API instance available on it (the first parameter). Additionally, the events are triggered with the dt namespace. As such, to listen for this event, you must also use the dt namespace by simply appending .dt to your event name, as shown in the example below.

Note: As of 1.11.0 this event is triggered regardless of the stateSave option. This allows the most recent state to always be tracked and available to users.

Type

function function( e, settings, data )

Parameters:

Example

Remove a saved filter, so filtering is never saved:

$('#example')
	.on('stateSaveParams.dt', function (e, settings, data) {
		data.search.search = '';
	})
	.DataTable();

Related

The following options are directly related and may also be useful in your application development.