Updating Initial Adaptable State
Summary
- After go-live, you can still ship design-time updates without wiping the rest of User State
- A numeric
Revision(orUpdateStrategy: 'Override') replaces an entire section of State - Alternatively,
UpdateStrategy: 'KeepUserDefined'refreshes design-time items while keeping user-created ones - Apply on next load, or at runtime via the State API — no grid remount required
Find Out More
- For first-time setup see Providing Initial Adaptable State
- See Adaptable State Persistence and the State Management Module for additional context
Why Update Initial State?
Initial Adaptable State is meant for first-time use.
Design-time objects are merged into User State once, then users change and persist their own configuration each time they use their application.
But later you might need to change those design-time defaults.
For instance you might want to add a new Format Column, an updated Custom Sort, a ReadOnly flag — but without clearing everything else the user has saved.
That is what the per-section Revision property is for.
Caution
- Revision is not a substitute for first-time Initial State
- Nor is it a full wipe of State (for that use
reloadInitialState/ Clear User State)
How Revision works
Every User State section implements BaseState, which includes Revision defined as follows:
Revision?: number | { Key: number; UpdateStrategy: 'Override' | 'KeepUserDefined' };Key Rules:
- Revision is per section (e.g. Format Column, Layout); bumping one section leaves other sections alone
- Update runs only if new Revision Key (or numeric value) is higher than what's already stored in User State
- On load AdapTable compares Initial State to persisted State, applying sections where Revision has increased
Note
The same things happen when you call the runtime merge APIs described below
Choosing a Strategy
The UpdateStrategy choice is between 'Override' or 'KeepUserDefined' and is as follows:
Number / Override | KeepUserDefined | |
|---|---|---|
| What happens to the section | Fully replaced by Initial State | Design-time items replaced; user-created items kept |
| User-created objects in that section | Lost | Kept |
| Best when | You want to reset that Module’s config from Initial State | Users may have added their own objects and you only want to refresh defaults |
| Typical shape | Revision: 2 or { Key: 2, UpdateStrategy: 'Override' } | Revision: { Key: 2, UpdateStrategy: 'KeepUserDefined' } |
Hint
A plain number is shorthand for Override — replace only, no merging of user items
Replacing Entire Section
Increment (or introduce) a numeric Revision on the section you want to replace.
AdapTable swaps (essentially overrides) that section in User State for the new Initial State contents.
Caution
A number is replace only — user-created items in that section are removed
export default {
CustomSort: {
// Replaces the Custom Sort section in User State when Revision 2
// is higher than the stored value. Other sections stay untouched.
Revision: 2,
CustomSorts: [
{
Name: 'CustomSort-Rating',
ColumnId: 'Rating',
SortedValues: ['AAA', 'AA+', 'AA', 'AA-'], // etc.
},
],
},
} as InitialState;- Starts with Format Column Revision
1stylingName(blue) - Add User Format Column calls the API to create a runtime Format Column on
Language(green) - Apply Revision 2 calls
stateApi.applyInitialState()— the new Initial State (Format Column Revision2containing onlyGithub Starsin yellow) is merged into the live user state, no page reload - Because Revision is a number (Override), the whole Format Column section is replaced — the user
Languagestyle is removed - Other sections (e.g. Layout) are unchanged
- Reset Demo clears persisted state and reloads the page to start again from Revision 1
- Confirm
Nameis blue - Click Add User Format Column —
Languageturns green - Click Apply Revision 2 — only
Github Starsis styled (yellow);Nameand userLanguagestyles are gone - Click Reset Demo to restore Revision 1
Keeping User-Created Items
For a more granular update, use the object form:
Key— bump whenever you ship a new version of that sectionUpdateStrategy: 'KeepUserDefined'— replace items that came from Initial State; keep items users created at run-time
Note
- AdapTable tells them apart via each Adaptable Object’s
Sourceproperty ('InitialState'vs'User'). - Items with
Source !== 'InitialState'are treated as user-defined and retained
This is the usual way to re-apply design-time objects on top of already persisted state — for example change a Format Column background, or mark it IsReadOnly.
Important
- Re-include every Initial State item you still want (with any updated properties)
- An omitted design-time item is dropped, even with
KeepUserDefined - Only user-created items are preserved automatically
export default {
CustomSort: {
// Replaces design-time Custom Sorts; keeps any user-created ones
Revision: {Key: 5, UpdateStrategy: 'KeepUserDefined'},
CustomSorts: [
{
Name: 'CustomSort-Rating',
ColumnId: 'Rating',
SortedValues: ['AAA', 'AA+', 'AA', 'AA-'], // etc.
},
],
},
} as InitialState;- Starts with Format Column Revision
1stylingName(blue) - Add User Format Column calls the API to create a runtime Format Column on
Language(green) - Apply Revision 2 calls
stateApi.applyInitialState(); Revision2lists empty Format Column array, so design-time items (Namestyle) are removed but user-created ones are kept; e.g.Language(if added) - Apply Revision 3 calls
stateApi.applyInitialState(); Revision3adds a new design-timeGithub Starsstyle (yellow) on top, still keeping user-created Format Columns - Both merges happen live in the user state — no page reload happens
- Reset Demo clears persisted state and reloads the page to start again from Revision 1
- Confirm
Nameis blue - Click Add User Format Column —
Languageturns green - Click Apply Revision 2 —
Nameblue is gone, but userLanguagestays green - Click Apply Revision 3 —
Github Starsturns yellow and userLanguageremains green - Click Reset Demo to restore Revision 1
Applying at Run-time
Revision merges also run at startup.
To deploy a new Initial State (or re-sync) without remounting the grid, use State API functions:
| API | What it does | Use when |
|---|---|---|
applyInitialState | Merges Initial State into the current in-memory user state (same Revision rules). If you pass an argument, also updates AdaptableOptions.initialState. | You have new Initial State in hand and want to apply it now |
remergePersistedState | Calls StateOptions.loadState, then merges with the current Initial State | Persistence changed elsewhere (or Initial State in options was updated) and you want to re-sync without a wipe |
reloadInitialState | Clears persisted state and reloads from Initial State | You intentionally want a full wipe back to Initial State |
Both applyInitialState and remergePersistedState persist afterward and refresh the grid / theme. Prefer them over remounting when shipping section Revisions at runtime.
Note
- The State Management Module UI can also load Initial State from a JSON file
- That replaces state from the file rather than applying a Revision merge
FAQ
Does bumping Revision wipe other Modules’ State? No. Only the section whose Revision increases is updated; every other section of User State is left alone.
What if the new Revision Key is not higher than the stored one?
AdapTable ignores the update for that section.
Always bump Key (or the numeric Revision) when you ship a new version.
Can I use { Key, UpdateStrategy: 'Override' } instead of a number?
Yes. A plain number is equivalent to Override.
Use the object form when you need KeepUserDefined, or when you want the strategy spelled out explicitly.
How does AdapTable know which items are “user-created”?
Adaptable Objects carry a Source of 'InitialState' or 'User'.
For KeepUserDefined, items whose Source is not 'InitialState' are kept and concatenated with the new Initial State.