≡

stateRestore

Since: StateRestore 2.0.0

StateRestore base configuration object.
Please note - this property requires the StateRestore extension for DataTables.

Description

StateRestore is a state management library for DataTables. It provides the following features:

  • Two state management interfaces to suit your needs:
    • Table based
    • Dropdown list based
  • Default state for when a table is loaded
  • First class Ajax storage
  • Optional sharing of states
  • Bookmarkable states
  • Customisation of which table settings are saved
  • Comprehensive API

There are two parts to enabling StateRestore for DataTables. The first is through this parameter, which is used to initialise the state management control, and perform any initial actions while the table is being loaded (e.g. checking for a bookmarked state or loading a default state). Set this option to true to make use of the defaults, or use as an object to customise the options.

The second part to using StateRestore is to display a UI to manage the states. This can be done with Buttons - e.g. stateList or stateTable, or through a custom UI that utilises the API if you prefer.

Types

boolean

When set to be true, this option will cause StateRestore to initialise along with the host DataTable, with its default parameters used for the configuration. If false, then StateRestore will not be configured.

object

As an object, this option provides a way to define configuration options for StateRestore so you can customise it for your needs.

Examples

Default configuration:

new DataTable('#myTable', {
	layout: {
		topStart: {
			buttons: ['stateCreate', 'statesList', 'pageLength']
		}
	},
	stateRestore: true
});

Ajax load and save state information:

new DataTable('#myTable', {
	layout: {
		topStart: {
			buttons: ['stateCreate', 'statesList', 'pageLength']
		}
	},
	stateRestore: {
		ajax: '/states/myTable'
	}
});

Related

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