useGridUndoRedo
Hook for programmatic undo/redo control.
Must be used within a DataGrid component tree with undoRedo and editing enabled.
useGridUndoRedo(selector: string): UndoRedoMethodsParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
selector | string | Optional 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'. |
Example
Section titled “Example”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