stateRestore.activeStates()

Since: StateRestore 1.0.1

Get the details of all of the currently active states.
Please note - this property requires the StateRestore extension for DataTables.

Description

This method provides the ability to retrieve details about all of the currently active states that are managed by the StateRestore extension. It is worth keeping in mind here that multiple states can be active at any one time (e.g. one which specifies only a filter, and another which specifies only an ordering condition for example).

A DataTables API instance is returned containing information about all of the active states. The objects in the result set are of type StateRestore.State.

Type

stateRestore.activeStates()

Retrieves any currently active states.

Returns:

DataTable.Api:
Returns a DataTables API instance containing an array of details about the states that are currently active (type StateRestore.State).

Example

Get the currently active states:

const table = new DataTable('#myTable', {
	layout: {
		topStart: {
			buttons: ['stateCreate', 'statesList']
		}
	}
});

// Button to get the current active states
document.querySelector('#getStates', function () {
	console.log(
		table.stateRestore.activeStates().toArray()
	);
});