Setup the loading and saving of states over ajax.
Please note - this property requires the StateRestore extension for DataTables.
This option allows StateRestore to load and save states over ajax. If the value provided for this option is a string, StateRestore will use it as the destination url for requests via ajax.
Setting the value to a function allows users to customise the behaviour when loading states into StateRestore, renaming, removing or saving states. There are no restrictions on the behaviour of the function - you can do whatever you please when this is called.
As default the value is
false, meaning that the states will be saved in the local session storage. Setting the value of this option to
true has no effect.
Take a look at this example to see this in action.
falseif ajax is not to be used. If ajax is to be used then this should be set to a string so that StateRestore can send requests to the appropriate location.
This option should be set to a string when StateRestore is to attempt to use ajax to load and save states. This string should be a url to tell StateRestore where it should make requests.
This function is called whenever
- States are loaded into StateRestore
- A state is renamed
- A state is removed
- A state is saved
It takes two parameters. The first is
datathat contains all of the data necessary to process the action. The second is a call back function that should be called when loading states via the ajax function. Being able to set this option as a function allows users greater flexibility in how they want to store their states.
Name Type Optional 1
The relevant data that would be passed over ajax. The object contains 2 properties.
stringThe type of action that is taking place to cause the ajax call. One of
objectThis object contains a property for each state that is to be affected by the call. The value when doing a save or a remove is the state object that it should store. When renaming this is slightly different and the value is the new name that should overwrite the value for the corresponding key. This property is not present when states are being loaded.
This callback can perform two different purposes depending on the action that is being performed.
In the first instance when predefined states are being loaded into StateRestore via the ajax function. In this case the
data.actionproperty will be set to
load. It takes a single argument that should have the same structure as
For all other possible actions this callback must be run whenever the action has succesfully been performed. In this case it takes no extra parameters.
The default value for the
stateRestore.ajax option is
false meaning that as standard the creation and saving of states will be done using the local session storage.
Set ajax url for StateRestore to send requests to: