Skip to content

useGridUndoRedo

Hook for programmatic undo/redo control.

Must be used within a DataGrid component tree with undoRedo and editing enabled.

useGridUndoRedo(selector: string): UndoRedoMethods
NameTypeDescription
selectorstringOptional CSS selector to target a specific grid element via
DOM query instead of using React context. Use when the component contains
multiple grids, e.g. 'tbw-grid.primary' or '#my-grid'.
import { useGridUndoRedo } from '@toolbox-web/grid-react/features/undo-redo';
function UndoRedoControls() {
const { undo, redo, canUndo, canRedo, clearHistory } = useGridUndoRedo();
return (
<div>
<button onClick={undo} disabled={!canUndo()}>Undo</button>
<button onClick={redo} disabled={!canRedo()}>Redo</button>
<button onClick={clearHistory}>Clear History</button>
</div>
);
}
AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt