@kanunilabs/datagrid-react / UseGridEditingResult
Interface: UseGridEditingResult<TRow>
Type Parameters
TRow
TRow = GridRowData
Properties
addRow
addRow: (
values?,beforeKey?,options?) =>RowKey|null
Adds a pending row and opens its first editable cell. Null when not allowed.
beforeKey puts it directly above that row instead of at the end — what
the Insert key needs.
Parameters
values?
Record<string, unknown>
beforeKey?
options?
open?
boolean
position?
Returns
RowKey | null
api
api:
EditingApi<TRow>
The app-facing editing API (P-1): one object for the life of this hook,
forwarding to the current engine — see EditingApi.
beginEdit
beginEdit: (
rowKey,columnId) =>void
Parameters
rowKey
columnId
string
Returns
void
beginRowEdit
beginRowEdit: (
rowKey,options?) =>boolean
Open a whole ROW (row / form / popup modes). False when the mode does not
support it, or another row is already open — the caller decides what to
do with the first one rather than having it saved or discarded silently.
standalone: in any mode — a card's popup (P-9; see the engine).
Parameters
rowKey
options?
standalone?
boolean
Returns
boolean
blurCommitSuspended
blurCommitSuspended: () =>
boolean
True while a custom editor's dialog holds suspendBlurCommit(true).
Returns
boolean
cancelCellEdit
cancelCellEdit: () =>
void
Close the open cell editor without keeping its value and give focus back
to the grid (the editors' Escape). Under commitOn: 'row' a new row left
empty by it is dropped, never sent (P-10).
Returns
void
cancelChanges
cancelChanges: () =>
void
Returns
void
cancelRowEdit
cancelRowEdit: () =>
void
Discard the open row's edits. Other rows keep theirs.
Returns
void
clearSaveError
clearSaveError: () =>
void
Dismiss the save error once the user has read it.
Returns
void
commitCellEditor
commitCellEditor: (
move) =>void
The built-in cell editor's commit (Enter, blur, a picked item), shared by
both renderers. 'down' moves to the cell below afterwards — unless
editKeys.enter is on, where Enter stays on the cell (P-7.1). 'blur':
focus has already gone where the user put it, so it is not pulled back to
the grid (P-10: a click on a field outside the grid must keep that field).
Parameters
move
"none" | "down" | "blur"
Returns
void
commitCustomEditor
commitCustomEditor: (
move) =>boolean
A custom editor's commit (renderEditor's ctx.commit, P-4.2): 'none'
stays on the cell, 'down' moves down (whatever editKeys.enter says —
the editor asked), 'enter' is the grid's own Enter (down unless
editKeys.enter), 'next' / 'previous' walk to the adjacent editable
cell like Tab, 'blur' leaves focus where it is. False when a rule
refused the value.
Parameters
move
"previous" | "next" | "none" | "down" | "enter" | "blur"
Returns
boolean
copySelection
copySelection: () =>
boolean
Copy the selected RANGE. False when no range is selected, which lets the Community row copy take the gesture instead.
Returns
boolean
cut
cut: (
target?) =>boolean
Copy the selected RANGE, then clear the cells the user may clear. One undo step. False when there was nothing to cut.
Cells the permissions refuse are copied but left in place: the user asked for the part they own, and refusing the whole rectangle over one read-only column would be the less useful answer.
Parameters
target?
{ columnId: string; rowKey: RowKey; } | null
Returns
boolean
deleteRow
deleteRow: (
rowKey) =>boolean
Parameters
rowKey
Returns
boolean
doubleClickEdits
doubleClickEdits:
boolean
editKeys.doubleClick — a double-click / double-tap opens an editor.
editAdjacentCell
editAdjacentCell: (
direction,options?) =>boolean
Commit and move to the next (1) or previous (-1) editable cell. By default
the destination is only FOCUSED; pass open: true to carry the editor
along, cycle: false to stop at the end of a row instead of wrapping.
Parameters
direction
-1 | 1
options?
cycle?
boolean
open?
boolean
Returns
boolean
editFocusedCellWith
editFocusedCellWith: (
char) =>boolean
Open the editor on the focused cell, seeded with a typed character.
Parameters
char
string
Returns
boolean
endFillDrag
endFillDrag: () =>
void
Returns
void
engine
engine:
EditingEngine<TRow> |null
fillPreview
fillPreview:
CellRange|null
focusScroller
focusScroller: () =>
void
Return DOM focus to the grid's scroller. Closing an editor destroys the element that held focus, so every path that ends a session has to call this or the keyboard goes dead until the user clicks the grid again.
Returns
void
handleKeyDown
handleKeyDown: (
event) =>boolean
Parameters
event
KeyboardEvent
Returns
boolean
isDraggingFill
isDraggingFill:
boolean
keyContext
keyContext: () =>
GridKeyContext
What the app's onKeyDown hook is told (P-7.2).
Returns
moveFillDrag
moveFillDrag: (
row,column) =>void
Parameters
row
number
column
number
Returns
void
paste
paste: (
target?) =>Promise<void>
Paste the clipboard over the range, anchored at its top-left cell. With no
range, at target (the cell a context menu was opened over), else at the
focused cell. Cells the permissions refuse are skipped, as cut skips them.
Parameters
target?
{ columnId: string; rowKey: RowKey; } | null
Returns
Promise<void>
pendingDelete
pendingDelete:
PendingDelete|null
A delete waiting on confirmation, or null.
range
range:
RangeApi
resolveDelete
resolveDelete: (
confirmed) =>void
Answer the confirmation: true deletes, false abandons.
Parameters
confirmed
boolean
Returns
void
rowSaveError
rowSaveError:
string|null
Message from the last rejected row save; null once anything changes.
saveChanges
saveChanges: () =>
Promise<void>
Returns
Promise<void>
saveError
saveError:
BatchSaveError|null
Why the last save was refused, or null.
saveRowEdit
saveRowEdit: () =>
Promise<boolean>
Validate and persist the open row. Resolves false and stays open on failure.
Returns
Promise<boolean>
selectionStats
selectionStats:
SelectionStats|null
Totals for the current range, or null when nothing is selected.
startFillDrag
startFillDrag: (
row,column) =>void
Parameters
row
number
column
number
Returns
void
suspendBlurCommit
suspendBlurCommit: (
on,restoreTo?) =>void
ctx.suspendBlurCommit (P-4.1): while on, blur is not leaving the editor
(ctx.commitOnBlur, the commitOn: 'row' send). Turning it off puts focus
that fell to <body> back on the editor (restoreTo), else the scroller.
Parameters
on
boolean
restoreTo?
() => HTMLElement | null
Returns
void
version
version:
number
Bumped on every engine change; consumers read through it.