OGE logoOGE

State Persistence

The grid's whole UI state — sorting, filters, grouping, column widths, order, pins and visibility — is one serializable snapshot. Persist it automatically with stateKey (localStorage by default, any sync or async backend via OGE_STATE_STORAGE), or take full control with state() / applyState() and the stateChange event.

stateKey OGE_STATE_STORAGE state() applyState() stateChange
stateKey localStorage

Sort, filter, group, resize or hide columns — then reload the page: everything comes back.

Drag a column header here to group
No commands to display
Id
First Name
Last Name
Department
Salary
1
Ali
Demir
HR
117000
2
Zeynep
Kılıç
Support
96000
3
Selin
Öztürk
HR
100000
4
Zeynep
Çelik
Engineering
78000
5
Emre
Şahin
HR
86000
6
Selin
Aydın
Support
46000
7
Deniz
Öztürk
Engineering
111000
8
Mehmet
Kılıç
Sales
93000
60 rows

Custom backend (API, database, IndexedDB…)

Provide OGE_STATE_STORAGE anywhere in the injector tree — both methods may return promises, so an HTTP backend plugs in directly. The demo below saves through a fake API with 250ms latency; watch the calls on the right.

OGE_STATE_STORAGE async
First Name
Department
Salary
Mert
Finance
112000
Elif
Support
95000
Mert
HR
47000
Mert
HR
36000
Ali
Sales
56000
Ayşe
Sales
101000
30 rows

Fake API log (250ms latency)

  1. Sort or filter the grid…

Imperative: state() / applyState() / stateChange

No token needed: read the snapshot with state(), apply one with applyState(), and react to stateChange (debounced) to persist on your own terms — e.g. a Save view button or per-user server profiles.

state() applyState() stateChange
stateChange fired 0 times
Drag a column header here to group
No commands to display
First Name
Department
City
Salary
Ali
HR
İstanbul
117000
Zeynep
Support
İzmir
96000
Selin
HR
Ankara
100000
Zeynep
Engineering
İzmir
78000
Emre
HR
İstanbul
86000
Selin
Support
Ankara
46000
60 rows

Last stateChange payload

—

Notes

  • The snapshot is plain JSON (GridStateSnapshot from @oge-ui/core) — safe to store, diff, and version.
  • Saves are debounced (250ms), so rapid interactions produce one write.
  • Restore is async-aware: with an API backend the grid renders immediately and applies the state when it arrives — unless the user already navigated to another stateKey.
  • applyState() also works across grids: capture on one, apply to another with the same columns.