Skip to content

Save and Restore Board State

Choose what you want to remember: card data, column order, collapsed presentation or the current view. Your application chooses storage and permissions; saving locally is not the same as persisting changes on a server.

Interactive example

Save and restore your board

This app saves cards and column order in the example’s memory.

Try it: Save this board, change it, then restore the saved copy.

Loading example…

What to notice: The original cards and column order return. Reset clears the saved copy.

TypeScript source

Install the packages from Getting Started, then use this source in your app.

state-and-filtering.ts
import type { KanbanPlugin } from '@revolist/kanban';
import type { WorkCard } from './first-board';
export function showHighPriority(kanban: KanbanPlugin<WorkCard>) {
kanban.setFilter({ predicate: card => card.priority === 'high' });
}
export function searchResearch(kanban: KanbanPlugin<WorkCard>) {
kanban.setFilter({ query: 'research', fields: ['title'] });
}
export function clearFilters(kanban: KanbanPlugin<WorkCard>) { kanban.setFilter(); }
// An app-owned snapshot of serializable data, not a Kanban remote-store API.
export function captureBoard(kanban: KanbanPlugin<WorkCard>) {
return { cards: kanban.getCards().map(card => ({ ...card })), columns: [...kanban.getColumnOrder()], collapsed: [...kanban.getCollapsedColumnProps()], selected: [...kanban.getSelectedCardIds()] };
}
export async function restoreBoard(grid: HTMLRevoGridElement, kanban: KanbanPlugin<WorkCard>, saved: ReturnType<typeof captureBoard>) {
grid.source = saved.cards.map(card => ({ ...card }));
await new Promise<void>(resolve => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
kanban.setColumnOrder(saved.columns);
for (const prop of kanban.getColumnOrder()) kanban.setColumnCollapsed(prop, saved.collapsed.includes(prop));
kanban.setSelectedCardIds(saved.selected);
}
// Persist JSON.stringify(captureBoard(kanban)) in your application's storage.
// Restore only data validated by your application; the live example stays in memory.
Download state-and-filtering.ts

Try it: save the example, change its cards or layout, then restore. The example keeps its saved copy in memory; Reset discards it.

For a ready Kanban plugin:

const saved = {
cards: kanban.getCards(),
columnOrder: kanban.getColumnOrder(),
collapsedColumns: kanban.getCollapsedColumnProps(),
collapsedLanes: kanban.getCollapsedSwimlaneIds(),
laneLabelsCollapsed: kanban.getSwimlaneColumnCollapsed(),
};
localStorage.setItem('my-board', JSON.stringify(saved));

This example assumes your application cards are JSON-safe. Rehydrate special values, validate stored data and recreate callback functions according to your application’s schema. Do not serialize projected rows from getProjection() as if they were application cards.

Load saved card records into grid.source, then reapply the presentation you chose to save. Use setColumnOrder, setColumnCollapsed and setSwimlaneColumnCollapsed for their respective presentation state. To restore lane collapse, provide explicit swimlanes definitions with the saved collapsed flags.

Replacing source data clears local Kanban history. Saved data may be stale; reconcile it with your backend before replacing a newer server board.

Use the optional async approval and persistence adapter for atomic versioned writes, precise rollback, retries and server-approved history. It captures canonical CRUD, moves and history once; do not add a second save listener.

For manually managed integrations without the adapter, kanbancardmove exposes changedCards, including every rank-rebalanced neighbor. Persist them atomically. beforekanbancardmove remains a synchronous veto; use approveMove and moveCardsAsync when approval needs to await a server.

Continue with server-side saving, managed persistence or board/table views. See the Kanban API for exact types and signatures.