StateRestore 2

Friday 11th September, 2026
By Allan Jardine

StateRestore 2.0 is here! This extension adds state management controls to DataTables, with an easy-to-use UI for the end user, letting them select between different table states with a simple button click. StateRestore is the third library released in the DataTables Plus suite - a premium set of extensions that enhance the capabilities of DataTables.

Example

As always, an example is worth a thousand words. In the example below stateCreate and statesTable are used to create the buttons for the state management UI, with StateRestore in its default configuration:

NamePositionOfficeSalary
Tiger NixonSystem ArchitectEdinburgh$320,800
Garrett WintersAccountantTokyo$170,750
Ashton CoxJunior Technical AuthorSan Francisco$86,000
Cedric KellySenior JavaScript DeveloperEdinburgh$433,060
Airi SatouAccountantTokyo$162,700
Brielle WilliamsonIntegration SpecialistNew York$372,000
Herrod ChandlerSales AssistantSan Francisco$137,500
Rhona DavidsonIntegration SpecialistTokyo$327,900
Colleen HurstJavaScript DeveloperSan Francisco$205,500
Sonya FrostSoftware EngineerEdinburgh$103,600
Jena GainesOffice ManagerLondon$90,560
Quinn FlynnSupport LeadEdinburgh$342,000
Charde MarshallRegional DirectorSan Francisco$470,600
Haley KennedySenior Marketing DesignerLondon$313,500
Tatyana FitzpatrickRegional DirectorLondon$385,750
Michael SilvaMarketing DesignerLondon$198,500
Paul ByrdChief Financial Officer (CFO)New York$725,000
Gloria LittleSystems AdministratorNew York$237,500
Bradley GreerSoftware EngineerLondon$132,000
Dai RiosPersonnel LeadEdinburgh$217,500
Jenette CaldwellDevelopment LeadNew York$345,000
Yuri BerryChief Marketing Officer (CMO)New York$675,000
Caesar VancePre-Sales SupportNew York$106,450
Doris WilderSales AssistantSydney$85,600
Angelica RamosChief Executive Officer (CEO)London$1,200,000
Gavin JoyceDeveloperEdinburgh$92,575
Jennifer ChangRegional DirectorSingapore$357,650
Brenden WagnerSoftware EngineerSan Francisco$206,850
Fiona GreenChief Operating Officer (COO)San Francisco$850,000
Shou ItouRegional MarketingTokyo$163,000
Michelle HouseIntegration SpecialistSydney$95,400
Suki BurksDeveloperLondon$114,500
Prescott BartlettTechnical AuthorLondon$145,000
Gavin CortezTeam LeaderSan Francisco$235,500
Martena MccrayPost-Sales supportEdinburgh$324,050
Unity ButlerMarketing DesignerSan Francisco$85,675
Howard HatfieldOffice ManagerSan Francisco$164,500
Hope FuentesSecretarySan Francisco$109,850
Vivian HarrellFinancial ControllerSan Francisco$452,500
Timothy MooneyOffice ManagerLondon$136,200
Jackson BradshawDirectorNew York$645,750
Olivia LiangSupport EngineerSingapore$234,500
Bruno NashSoftware EngineerLondon$163,500
Sakura YamamotoSupport EngineerTokyo$139,575
Thor WaltonDeveloperNew York$98,540
Finn CamachoSupport EngineerSan Francisco$87,500
Serge BaldwinData CoordinatorSingapore$138,575
Zenaida FrankSoftware EngineerNew York$125,250
Zorita SerranoSoftware EngineerSan Francisco$115,000
Jennifer AcostaJunior JavaScript DeveloperEdinburgh$75,650
Cara StevensSales AssistantNew York$145,600
Hermione ButlerRegional DirectorLondon$356,250
Lael GreerSystems AdministratorLondon$103,500
Jonas AlexanderDeveloperSan Francisco$86,500
Shad DeckerRegional DirectorEdinburgh$183,000
Michael BruceJavaScript DeveloperSingapore$183,000
Donna SniderCustomer SupportNew York$112,000

As you will be able to see, the "Saved states" button will show a modal with the state management UI. You can also use statesList if you prefer a dropdown list of states (example here).

The initialisation code for the above table simply defines the buttons to show in a specific location, and enables the stateRestore option:

new DataTable('#blog-sr-demo', {
    layout: {
        topStart: {
            buttons: ['stateCreate', 'statesTable']
        }
    },
    stateRestore: true
});

New features

StateRestore 2.0 is a complete rewrite of the library with the following headline new features:

  • Ajax as first class storage for states
  • Ability to set a default state
  • Central configuration with a stateRestore option
  • Table view for state management
  • Smaller size

A primary focus for 2.0 was adding Ajax state storage as a first class part of the software. Fundamentally, states are most useful in a multi-user system where each user can define their own states. The ability to share states between users also falls out of this option, and when Ajax storage is used for StateRestore (stateRestore.ajax), users now have the option of selecting to share a state or not.

The server-side libraries for DataTables have all been updated to provide support for StateRestore with a new StateRestore class. An Ajax example is available and is part of the demo apps, along with full documentation for the Ajax data used.

Another goal of the rewrite was to architect it such that a state could be designated as a default state - that is, one which the table will be placed into when the table is initialised. As part of this work, the centralised stateRestore option was introduced for easy and consistent configuration.

The dropdown list view for states is simple and attractive, but it can become crowded if you expect your end users to have a large number of states. For this reason, a new table-based UI has been added (statesTable - shown in the example above), which has all the benefits of DataTables (ordering, search) allowing easy navigation of a large number of states.

Finally, for the headline features, all of this is provided in a 23K (minified, not gzipped) library, almost half the size of v1. As with all DataTables extensions, StateRestore is written in Typescript and dependency free, other than DataTables itself.

Upgrading

If you are updating from StateRestore v1, please be aware that there is a good chance you will need to make some changes to how the software is configured - you certainly will if you are using Ajax storage or any other options beyond the defaults. This is due to the introduction of the new stateRestore option, which significantly simplifies configuration for StateRestore.

An update note with further details is available. If you run into any issues upgrading, please get in touch.

Feedback welcome

As always with DataTables and its extensions, I very much welcome feedback. Often the software is used for cases which I didn't necessarily expect, and features that might be useful to you weren't immediately apparent to be during development! Please get in touch if you have any feedback on StateRestore and how you would like to see it develop.