Saved views
View sourceCapture the current sort / filter / group / column-state / pin / density into a typed BcSavedView DTO that you can persist anywhere — localStorage, a server endpoint, or the URL — and apply later with one call.
Try this
The demo's saved views live in component state — refreshing loses them. Real apps persist to localStorage / your API.
- Sort by a column, filter another, then click Save current view.
- Change the sort, then click your saved-view chip — the layout snaps back.
- Save a second view with different settings; click between them to switch.
- Click the × on a chip to delete that view.
The DTO
- createSavedView({ name, gridId, layout }). Returns a typed
BcSavedView<TRow>withid/version/createdAtstamped on. Persist it as JSON. - applySavedViewLayout(api, view). Mutates the grid imperatively to match the saved layout — sort, filter, group, column visibility / order / width / pin, density, the whole layout state. Migrates older versions automatically.
- migrateSavedViewLayout. Standalone migrator if you need to upgrade stored views before re-displaying them in a saved-view picker.
Where the layout comes from
The grid emits onLayoutStateChange every time the layout changes (debounced). Capture the latest state, hand it to createSavedView. Or pull it on demand with apiRef.current?.getLayoutState().
Server sync
For multi-device / multi-user saved views, see the saved-view-server-sync recipe in packages/bc-grid/docs/recipes/. The DTO carries a version + revision string so a client can do conflict-aware sync (last-writer-wins, merge, or prompt) without writing custom diff logic.