Get and set grid state round-trip
Introduces getState() and setState() as the single entry point for capturing and restoring the user-visible configuration of a WarGrid. The demo shows that a captured snapshot can be applied to a freshly mounted grid and produce a visually identical result. This is the foundation for every other persistence feature in this area.
Planned. This page shows the specification from issue #201. The live example, source for every framework and the API reference replace it when the feature ships.
Live example
A 200-row employee grid with default column order, no sort, no filter and the first page shown. A read-only JSON panel beside the grid shows the most recent getState() output.
Expected behavior
The user resizes a column, sorts, filters and scrolls, then presses Capture and the JSON panel updates. The user then presses Remount and the grid returns to defaults. Pressing Apply restores the identical layout, sort, filter and scroll position, and fires onStateRestored once.
Planned API surface
getState()setState(state)GridStateinitialStateonStateRestoredAcceptance criteria
- getState() returns a plain JSON-serializable object with no functions, DOM nodes or circular references. (pending)
- setState(getState()) on the same grid produces no visible change and no data refetch. (pending)
- A state captured from grid A and applied to a freshly mounted grid B with the same column definitions renders an equivalent layout. (pending)
- onStateRestored fires exactly once per setState call, after rendering has settled. (pending)
- initialState applied at mount is equivalent to calling setState immediately after mount, but causes no flash of default layout. (pending)