Manually Saving Layouts
Summary
- The
updateCurrentLayoutfunction in Layout Api allows developers easily to update a Layout programatically - The
applyStatefunction 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
- This demo is a cut down version from examples provided in the Guide to Controlling AdapTable State Persistence
- See the demos there for full explanations and in-depth details of this advanced topic
Manually Saving Layouts
- 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 StateUndo Layout Changes- replaces any locally saved changes to Layouts with last saved version in AdapTable StateReset 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 StarsColumn are automatically persisted)