stateRestore.predefined
Set states that will be immediately available.
Please note - this property requires the StateRestore extension for DataTables.
Description
It can be useful to provide end users with a list of states that you expect to be the most commonly used, to allow them fast access into the system and the data you wish them to see prominently (e.g. specific sets of columns, or filters). This option provides that ability.
It is an array of StateRestore.Predefined objects, which can have the name, state and if it should be the default state defined.
The end user will not be able to edit or delete states which are defined with this property. Furthermore, when combined with stateRestore.canCreate, you can use this to create a set of static states that the user cannot add to either.
Types
array
As an array, it will contain objects of type StateRestore.Predefined, with each entry in the array being a state that the end user can select from.
object
For backwards compatibility with states from StateRestore v1, this option can also be given as an object, where each key / value pair is the name of the state and the DataTable state itself.
Using as an object is very much discouraged. Use the array option above for the full range of features.
Example
Set predefined states:
new DataTable('#example', {
layout: {
topStart: {
buttons: ['stateCreate', 'statesList']
}
},
stateRestore: {
predefined: [{
name: 'Search - London',
state: {
search: {
search: 'London'
}
}
}, {
name: 'Order - Position',
state: {
order: [[1, 'asc']]
}
}, {
name: 'Search and order',
state: {
order: [[5, 'asc']],
search: {
search: 'San Francisco'
}
}
}]
}
});