StateRestore

StateRestore extends DataTables' stateSave option, allowing multiple states to be saved and reloaded at any time. There is also the possibility to customise which elements of DataTables are stored in each saved state.

This will be very useful for returning to previous setups quickly and easily. The states can be saved locally, or over ajax. It is also possible to set predefined states that will appear for all users.

Download

The easiest way to get and use StateRestore is to use the DataTables download builder where you can select the software that you wish to use on your page and have a single Javascript and CSS file created and hosted for you. As well as choosing the StateRestore package, you also have to add the dependent Buttons package.

Alternatively, the individual files can be included on your page, a release package downloaded or the source control repository cloned on GitHub.

Initialisation

If you include the StateRestore extension on your page, it is automatically available for every DataTable on that page. It is used via Buttons and configuration for StateRestore goes inside of the various StateRestore buttons config objects.

// Simple initialisation:
new DataTable('#myTable', {
    layout: {
        topStart: {
            buttons: ['createState', 'savedStates']
        }
    }
});

// Or, with configuration options:
new DataTable('#myTable', {
    layout: {
        topStart: {
            buttons:[
                'createState',
                {
                    extend: 'savedStates',
                    config: {
                        // config options here
                    }
                }
            ]
        }
    }
});

The simple initialisation will automatically enable the StateRestore on your table. Some of the customisation options include, predefined states, control over various modals and also which elements of DataTables are saved. Please refer to the reference documentation for full details of the options available.

Features

StateRestore adds the following features:

  • Advanced State Saving functionality
  • Save and Reload an unlimited number of states
  • Allow users to select which elements of DataTables are saved
  • Predefined states for all users
  • Fully internationalisable
  • Full integration with Bootstrap, Foundation and the other styling libraries supported by DataTables