Undo/Redo Plugin

Understand the current undo/redo integration surface.

The undo/redo plugin is installed by the core grid setup and emits state changes, but the everyday Grid instance does not currently expose a first-class grid.undoRedo namespace.

Event

undo-redo-event.ts
grid.on('undo-redo:change', ({ canUndo, canRedo, undoCount, redoCount }) => {
updateToolbar({ canUndo, canRedo, undoCount, redoCount });
});

Advanced Access

Plugin methods are registered in the low-level API registry. Use this only for advanced integrations.

advanced-undo-redo.ts
const api = grid.getGridApi();
const undo = api.getMethod('undoRedo', 'undo');
const redo = api.getMethod('undoRedo', 'redo');
const canUndo = api.getMethod('undoRedo', 'canUndo');
const canRedo = api.getMethod('undoRedo', 'canRedo');
undo?.();
redo?.();
console.log(canUndo?.(), canRedo?.());
Warning

Wrap getGridApi() calls in your own adapter before using them in production workflows. This surface is intended for plugin-level integrations.

App-Owned History

For critical editing workflows, keep an application-level history from edit:commit.

app-history.ts
const history: Array<{ row: number; col: number; oldValue: unknown; newValue: unknown }> = [];
grid.on('edit:commit', ({ cell, oldValue, newValue }) => {
history.push({ row: cell.row, col: cell.col, oldValue, newValue });
});