useGridImperative
useGridImperative: generated from the source of active-grid.
Exported by @workspace/. Generated from the package source; part of the index of every export.
Functions, hooks and constants#
Typed wrapper for an Active's imperative API. Returns stable callbacks that safely no-op when the ref isn't attached yet.
Preferred over reading grid inline because:
- The returned callbacks are typed against
TDataforadd.Row - Each callback is stable across re-renders.
- Passing the result through context-menu / dialog builders avoids the
react-lint warning that fires when a ref-reading function is invoked during render.hooks/ refs
Usage:
```tsx const gridRef = useRef<GridImperativeHandle>(null); const grid = useGridImperative<Record>(gridRef);
const handleDelete = async (id: string) => { const result = await deleteAction(id); if (result.success) grid.removeRow(id); }; ```
Client-mode caveat: add/remove are no-ops in mode="client" because client-mode reads directly from the data prop. Mutate your own data state (set) for client-mode grids. The grid emits a dev-time warning if these are called in client mode.
<TData = unknown>(gridRef: RefObject<GridImperativeHandle | null>) => UseGridImperativeResult<TData>Returns
An object with these fields.
- Type
() => void
Invalidate server cache and re-fetch current page. No-op in client mode.
- Type
(rowId: string) => void
Remove a row from the local cache (server mode). In client mode, manage the data prop yourself — see README §Client-mode mutations.
- Type
(row: TData) => void
Add a row to the local cache (server mode). In client mode, manage the data prop yourself.
- Type
() => void
Clear all row selections.