Manually Saving Layouts

Summary

  • The updateCurrentLayout function in Layout Api allows developers easily to update a Layout programatically
  • The applyState function in State Options can be used to control when Layouts are saved

Layouts, like all AdapTable objects, save automatically as soon as they are changed.

Whenever a Column is grouped, resized, pinned etc, the change is immediately persisted to AdapTable State.

Sometimes this is not desired behaviour, and developers prefer to manually control when a Layout is saved.

In other words, run-time users can only make temporary changes to Layouts, and the actual state persistence is imperatively driven.

This is possible in AdapTable as the demo below demonstrates.

Note

Manually Saving Layouts
Fork
  • In this demo we prevent the auto-saving of Layouts
  • Changes to Layouts are not automatically saved in AdapTable State - instead we keep a local copy of the changes and we provide 3 Dashboard Buttons:
    • Persist Layout Changes - manually saves all changes to Layouts to AdapTable State
    • Undo Layout Changes - replaces any locally saved changes to Layouts with last saved version in AdapTable State
    • Reset Layout Changes - replaces any locally saved changes to Layouts with inital version in AdapTable State
  • Note: only Layouts are not auto-saved - changes to other objects (e.g. changing the back colour of the Format Column on Github Stars Column are automatically persisted)