stateRestore.state().isActive()

Since: StateRestore 2.0.0

Checks if the selected state is active.
Please note - this property requires the StateRestore extension for DataTables.

Description

When working with states, you might wish to know if a particular one is active. You can use stateRestore.activeStates() to get all currently active states, but if you are building a list of states for a custom UI, you might want to test each individual state. This method provides that ability.

Type

stateRestore.state().isActive()

Determines if the selected state is currently active or not.

Returns:

boolean: true if the state is active, false otherwise.

Example

List all states, and if they are active:

table.stateRestore.states().details().forEach(state => {
	if (table.stateRestore.state(state.id).isActive()) {
		console.log(`State ${state.id} is ACTIVE`);
	}
	else {
		console.log(`State ${state.id} is NOT active`);
	}
});

Related

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