Canvas API signatures

API catalog generated from the exported TypeScript Grid type. Use the package guide for behavior/examples and match the selected documentation version to your installed packages. Coordinates are zero-based visible indices unless a contract

npm 0.4.0Revision tài liệu 16Cập nhật 2026-10-2878fd206

Phạm vi package đã phát hành. Chọn đúng phiên bản package đang cài trong ứng dụng.

Nội dung kỹ thuật bằng tiếng Anh; điều hướng theo ngôn ngữ đã chọn.

Package guide · Version policy

Data and lifecycle

updateCellsAsync

updateCellsAsync: (updates: readonly CellUpdate[], options: GridBulkOptions) => Promise<void>

getValue

getValue: (rowIndex: number, columnKey: string) => unknown

replaceText

replaceText: (search: string, replacement: string, options?: Parameters<GridEngine["replaceText"]>[2]) => ReturnType<GridEngine["replaceText"]>

Available in 0.2.0: bounded literal replacement. One undo command; permission/validation failures leave the batch unchanged.

subscribe

subscribe: (subscriber: { readonly onEvent?: (event: GridEvent) => void; readonly onInvalidate?: (change: GridInvalidation) => void; }) => () => void

takeObserverErrors

takeObserverErrors: () => unknown[]

captureRowIdentity

captureRowIdentity: () => readonly RowId[]

Capture before external structural changes. Explicitly scans all row IDs.

refreshData

refreshData: (previousRowIds?: readonly RowId[] | "values") => void

External writes are outside history. All refresh modes clear undo/redo; values mode requires unchanged row IDs/order/count.

refreshRows

refreshRows: (startRow: number, endRow: number) => RowRefreshResult

Refresh a bounded row window through core without remounting. Reject while an editor or local search is open; finish/cancel or close it before retrying. See the core contract for history, selection, identity and layout restrictions.

resetData

resetData: () => DataResetResult

Reset through the bounded core epoch contract without remounting. Reject open editors or local Find; host must settle them before changing its source. Clear renderer caches, update count/ARIA/index geometry and move vertical scroll to zero. No identity anchor or source loading is performed.

rowCount

rowCount: number

columns

columns: readonly Column[]

render

render: () => void

Schedule a browser repaint. It is not an identity reconciliation command; use refreshData after external changes.

updateCells

updateCells: (updates: readonly CellUpdate[]) => void

Typed values; no parsing. Column validation and writable permissions run before one atomic write. Uses visible indices.

destroy

destroy: () => void

Release this instance. Idempotent; host-owned sources and external subscriptions still need host cleanup.

Selection and clipboard

pasteAsync

pasteAsync: (text: string, bulk: GridBulkOptions, options?: PasteOptions) => Promise<void>

selectColumn

selectColumn: (index: number) => void

selectRow

selectRow: (index: number) => void

selectAll

selectAll: () => void

getSelection

getSelection: () => CellSelection | null

getSelectionRange

getSelectionRange: () => SelectionRange | null

getSelectionRanges

getSelectionRanges: () => SelectionRange[]

cutSelectionBlocks

cutSelectionBlocks: () => string

cancelCut

cancelCut: () => void

copySelectionBlocks

copySelectionBlocks: () => string

pasteSelectionBlocks

pasteSelectionBlocks: (text: string, options?: PasteOptions) => void

copySelection

copySelection: () => string

TSV text through copy permissions. No direct operating-system clipboard access in core.

paste

paste: (text: string, options?: PasteOptions) => void

Parse TSV/editor text and preflight the complete destination before writing.

History

undoAsync

undoAsync: (options: GridBulkOptions) => Promise<boolean>

redoAsync

redoAsync: (options: GridBulkOptions) => Promise<boolean>

undo

undo: () => boolean

Replay the last command only if current identities/values/permissions allow it; returns whether replay occurred.

redo

redo: () => boolean

Reapply a previously undone command under current identity/value/permission checks.

Views and persistence

setGrouping

setGrouping: (next: LocalGroupingOptions | null) => void

Available in 0.4.0: filter complete local records, group by one scalar key and optionally sum finite numeric values; sort leaves within each group. Reject incompatible row layout/history before installing. Null clears grouping. No source writes.

grouping

grouping: Readonly<LocalGroupingOptions> | null

Frozen current local grouping criteria, or null. Grouping is separate from LocalViewOptions and server queries.

tree

tree: Readonly<LocalTreeOptions> | null

Frozen current parent-column criteria, or null. Tree projection is separate from LocalViewOptions and remote queries.

setTree

setTree: (next: LocalTreeOptions | null) => void

Available in 0.4.0: validate a complete local parent-ID forest, retain filter matches and ancestors, and sort siblings. Reject invalid IDs, parents, cycles, depth above 4096 and incompatible grouping/row layout/history before installing. Null clears tree; no source writes.

getTreeRowMetadata

getTreeRowMetadata: (row: number) => LocalTreeRow | null

Frozen metadata for a visible real tree record: sourceIndex, rowId, parentId, 1-based level, retained hasChildren and expanded. Null outside tree mode. No synthetic row ID.

setTreeExpanded

setTreeExpanded: (rowId: RowId, expanded: boolean) => void

Expand/collapse a visible branch by its real typed row ID, outside data undo. Reduce selection to its active visible cell or affected parent if hidden; discard hidden ranges. Unknown branches reject; unchanged expansion is a no-op.

exportTreeState

exportTreeState: () => TreeState

Frozen version-1 parent-column criteria and typed collapsed IDs. Contains no dataset provenance, records, permissions or history; the host selects the matching complete dataset.

restoreTreeState

restoreTreeState: (state: unknown) => void

Validate unknown version-1 state, schema, layout and collapsed IDs against the current forest before replacing tree projection atomically. Clears selection; does not restore source data or authority.

getRowMetadata

getRowMetadata: (row: number) => GridRowMetadata

Discriminated group/leaf metadata for a visible row. Only leaves have real sourceIndex and rowId; group metadata contains key, count, sums, retained source indices and expanded state. Legacy getRowId/getRowSourceIndex reject group rows.

focusGroup

focusGroup: (row: number) => boolean

Focus a group header and clear all data selection/cut targets. Returns false for a leaf. Group focus is separate from CellSelection.

getFocusedGroup

getFocusedGroup: () => number

Visible index of the focused group header, or -1. No synthetic CellSelection or RowId is created.

setDataGroupExpanded

setDataGroupExpanded: (key: GroupKey, expanded: boolean) => void

Expand/collapse a typed visible group key without changing source values, aggregates or data history. Clears leaf selection and focuses the header.

exportGroupingState

exportGroupingState: () => GroupingState

Frozen version-1 criteria/collapsed-key view snapshot, separate from legacy GridState/GridConfiguration. Contains no data, authorization or history; apply only to a matching host-owned dataset.

restoreGroupingState

restoreGroupingState: (state: unknown) => void

Validate unknown version-1 grouping state and schema/layout before installing atomically. Typed collapsed keys survive local filters. Does not restore source data or permissions.

setViewAsync

setViewAsync: (next: LocalViewOptions, options: GridBulkOptions) => Promise<void>

exportState

exportState: () => GridState

Domain UI state only: excludes row data, callbacks, source transport and undo history.

restoreState

restoreState: (state: unknown) => void

Validate unknown state before committing; application permissions cannot be replaced by saved state.

exportConfiguration

exportConfiguration: () => GridConfiguration

JSON-safe column order/widths, frozen counts and core-owned view; excludes data, callbacks and history.

setView

setView: (view: LocalViewOptions) => void

Set local sort/filter criteria, not a server query. Structural commands require clearing the projected view.

view

view: Readonly<LocalViewOptions>

Structure and groups

getMerge

getMerge: (row: number, col: number) => Readonly<SelectionRange> | null

getMergedCells

getMergedCells: () => readonly Readonly<SelectionRange>[]

canMerge

canMerge: (range: SelectionRange) => boolean

mergeCells

mergeCells: (range: SelectionRange) => void

unmergeCells

unmergeCells: (range: SelectionRange) => void

getRowGroups

getRowGroups: () => readonly Readonly<RowGroup>[]

groupRows

groupRows: (start: number, end: number) => string

ungroupRows

ungroupRows: (id: string) => void

setGroupCollapsed

setGroupCollapsed: (id: string, collapsed: boolean) => void

insertColumns

insertColumns: (index: number, columns: readonly Column[]) => void

deleteColumns

deleteColumns: (indices: readonly number[]) => void

insertRows

insertRows: (index: number, rows: readonly DataRow[]) => void

deleteRows

deleteRows: (indices: readonly number[]) => void

moveRows

moveRows: (indices: readonly number[], beforeIndex: number) => void

moveColumns

moveColumns: (indices: readonly number[], beforeIndex: number) => void

Permissions and formatting

isLocked

isLocked: (target: CellLockTarget) => boolean

canManageLocks

canManageLocks: () => boolean

setLocked

setLocked: (target: CellLockTarget, locked: boolean) => void

getFormat

getFormat: (rowIndex: number, columnIndex: number) => Readonly<CellFormat>

canFormat

canFormat: (targets: readonly CellFormatTarget[]) => boolean

format

format: (targets: readonly CellFormatTarget[], patch: CellFormatPatch | null) => void

getCellPermission

getCellPermission: (rowIndex: number, columnIndex: number) => CellPermission

Layout and browser controls

getMotion

getMotion: () => Readonly<Required<MotionOptions>>

setMotion

setMotion: (value: boolean | MotionOptions) => void

getViewport

getViewport: () => GridViewport

Read frozen shared core viewport geometry without scanning source values or IDs. Display ranges have exclusive ends and may be disjoint. onViewportChange coalesces geometry notifications in a microtask. The host owns bounded loading and eviction reconciliation.

setColumnEditor

setColumnEditor: (key: string, editor: ColumnEditor | null) => void

Replace a configured browser editor. Host callbacks remain trusted code.

setTheme

setTheme: (theme: Partial<GridTheme>) => void

Validated theme patch; does not recreate the grid or resize rows.

openSearch

openSearch: () => void

autoFitColumn

autoFitColumn: (index: number) => void

autoFitRow

autoFitRow: (index: number) => void

frozenRows

frozenRows: number

frozenColumns

frozenColumns: number

setRowsHidden

setRowsHidden: (indices: readonly number[], hidden: boolean) => void

setColumnsHidden

setColumnsHidden: (indices: readonly number[], hidden: boolean) => void

getHiddenRows

getHiddenRows: () => readonly number[]

getHiddenColumns

getHiddenColumns: () => readonly number[]

isRowHidden

isRowHidden: (index: number) => boolean

isColumnHidden

isColumnHidden: (index: number) => boolean

setFrozen

setFrozen: (rows: number, columns: number) => void

setColumnWidth

setColumnWidth: (index: number, width: number) => void

setRowHeight

setRowHeight: (index: number, height: number) => void

Construction options

Call createGrid with GridOptions. Required fields are marked; options are read at construction unless the package guide specifies a runtime setter.

Field Required Type
allowMerging No boolean | undefined
allowSearch No boolean | undefined
allowRowGrouping No boolean | undefined
canChangeLayout No ((request: Readonly<LayoutRequest>) => boolean) | undefined
locale No string | undefined
messages No Readonly<Record<string, string>> | undefined
currency No string | undefined
view No LocalViewOptions | undefined
viewMode No "core" | "host" | undefined
onViewChange No ((view: LocalViewOptions) => void) | undefined
onViewportChange No ((viewport: GridViewport) => void) | undefined
theme No Partial<GridTheme> | undefined
imageColumns No readonly string[] | undefined
avatarColumns No readonly string[] | undefined
mediaOptions No { readonly size?: number; readonly maxVisible?: number; readonly maxConcurrentUploads?: number; readonly upload?: (file: File, context: Readonly<{ columnKey: string; signal: AbortSignal; onProgress: (loaded: number, total?: number) => void; }>) => Promise<MediaItem>; } | undefined
columnEditors No Readonly<Record<string, ColumnEditor>> | undefined
richTextColumns No Readonly<Record<string, RichTextFormat>> | undefined
markdownToHtml No ((source: string) => string) | undefined
multilineEditor No boolean | undefined
editorOptions No { readonly pinned?: boolean; readonly showLabel?: boolean | "scroll" | "always"; readonly guardNavigation?: boolean; } | undefined
wrapText No boolean | undefined
detectLinks No boolean | undefined
allowOpenLinks No boolean | undefined
contextMenuSuggestions No boolean | undefined
linkPreview No boolean | { readonly enabled?: boolean; readonly allowMetadata?: boolean; readonly load: (href: string, signal: AbortSignal) => Promise<{ readonly title?: string; readonly description?: string; readonly image?: string; }>; } | undefined
accessibility No "active" | "viewport" | undefined
getCellLabel No ((rowIndex: number, columnKey: string, value: unknown) => string | undefined) | undefined
renderCell No CellRenderer | undefined
renderCellBackground No ((context: CanvasRenderingContext2D, cell: CellRenderInfo) => void) | undefined
createEditor No CellEditorFactory | undefined
onEditorMount No ((cell: Readonly<CellEditorInfo>, editor: CellEditor) => void | (() => void)) | undefined
onObserverError No ((error: unknown) => void) | undefined
choiceEditor No false | ChoiceEditorOptions | undefined
motion No boolean | MotionOptions | undefined
tableLockNotice No false | { readonly title?: string; readonly description?: string; } | undefined
selectionStyle No { readonly activeCellBorderInRange?: boolean; readonly activeBorderWidth?: number; readonly headerTintOpacity?: number; readonly rangeBorderWidth?: number; readonly rangeTintOpacity?: number; } | undefined
allowColumnChanges No boolean | undefined
columnTypes No readonly ColumnType[] | undefined
onRowChange No ((request: Readonly<RowChangeRequest>) => void) | undefined
canRowChange No ((request: Readonly<RowChangeRequest>) => boolean) | undefined
onReorder No ((request: Readonly<ReorderRequest>) => void) | undefined
canReorder No ((request: Readonly<ReorderRequest>) => boolean) | undefined
onSelectionChange No ((selection: CellSelection | null) => void) | undefined
onSelectionRangesChange No ((ranges: readonly SelectionRange[]) => void) | undefined
onSelectionRangeChange No ((range: SelectionRange | null) => void) | undefined
container Yes HTMLElement
columns Yes readonly Column[]
dataSource Yes DataSource
rowHeight No number | undefined
columnWidth No number | undefined
headerHeight No number | undefined
headerGroups No readonly HeaderGroup[] | undefined
autoRowHeight No boolean | undefined
measureCellHeight No ((value: unknown, columnKey: string, width: number) => number | undefined) | undefined
indexColumn No boolean | undefined
permissions No Partial<CellPermission> | undefined
canChangeStructure No ((request: Readonly<StructureRequest>) => boolean) | undefined
tree No LocalTreeOptions | undefined
grouping No LocalGroupingOptions | undefined
frozenRows No number | undefined
frozenColumns No number | undefined
resolveCellPermission No CellPermissionResolver | undefined
onEvent No ((event: GridEvent) => void) | undefined
allowLockChanges No boolean | undefined
columnWidths No Readonly<Record<string, number>> | undefined
canChangeVisibility No ((request: Readonly<{ axis: "row" | "column"; indices: readonly number[]; hidden: boolean; }>) => boolean) | undefined
historyLimits No GridHistoryLimits | undefined
Thay đổi gì
  • r1 — Generated source API signatures and construction options.
  • r2 — Generated source API signatures and construction options.
  • r3 — Generated source API signatures and construction options.
  • r4 — Generated source API signatures and construction options.
  • r5 — Generated source API signatures and construction options.
  • r6 — Generated source API signatures and construction options.
  • r7 — Generated source API signatures and construction options.
  • r8 — Generated source API signatures and construction options.
  • r9 — Generated source API signatures and construction options.
  • r10 — Generated source API signatures and construction options.
  • r11 — Generated source API signatures and construction options.
  • r12 — Generated source API signatures and construction options.
  • r13 — Generated source API signatures and construction options.
  • r14 — Generated source API signatures and construction options.
  • r15 — Generated source API signatures and construction options.
  • r16 — Generated source API signatures and construction options.
Tải Markdown
Phiên bản tài liệu