stateRestore.state.add()
Create a new state.
Please note - this property requires the StateRestore extension for DataTables.
Description
This method provides the ability to create a new state that is managed by the StateRestore extension.
stateRestore.state.add()
takes one argument, identifier
. This string is used to identify the state throughout StateRestore. It is used when naming the state in whatever storage method is selected and is also shown in the state's button.
The object that is returned within the DataTables API result set, represents the state that is present in the table at the time of saving.
Type
function stateRestore.state.add()
- Description:
Creates a new StateRestore instance.
- Parameters:
Name Type Optional 1 identifier
No The string that is used to identify this state. This must be unique in order to differentiate between the different states that may be stored within StateRestore.
- Returns:
Returns a DataTables API for chaining, with the object containing the state that has been extracted from the table in the result set.
Example
Add a new state called 'New State':
var table = new DataTable('#myTable', {
layout: {
topStart: {
buttons: ['createState', 'savedStates']
}
}
});
table.stateRestore.state.add('New State');