API reference: @salmonui/gantt
GanttApiinterface
import type { GanttApi } from '@salmonui/gantt';interface GanttApi<Row = Record<string, unknown>> extends Omit<DataGridApi<Row>, 'cancelEdit' | 'getState' | 'restoreState' | 'exportToExcel' | 'exportToCsv' | 'exportToPdf' | 'print' | 'undo' | 'redo' | 'setLoading'> {
readonly grid: DataGridApi<Row>;
getTask(id: RowId): Row | undefined;
getTaskInfo(id: RowId): GanttTaskInfo | undefined;
getViewRows(): readonly Row[];
getCriticalTasks(): readonly Row[];
formatDuration(id: RowId): string;
formatWork(id: RowId): string;
addTask(task?: Partial<Row>, options?: {
readonly position?: 'top' | 'bottom' | 'above' | 'below' | 'child';
readonly targetId?: RowId;
}): GanttActionResult;
updateTask(id: RowId, changes: Partial<Row>): GanttActionResult;
deleteTasks(ids: RowId | readonly RowId[]): GanttActionResult;
changeTaskId(id: RowId, newId: RowId): GanttActionResult;
cancelEdit(): void;
indent(ids: RowId | readonly RowId[]): GanttActionResult;
outdent(ids: RowId | readonly RowId[]): GanttActionResult;
moveTasks(ids: RowId | readonly RowId[], targetId: RowId, position: 'above' | 'below' | 'child'): GanttActionResult;
addDependency(taskId: RowId, dependency: Dependency | string): GanttActionResult;
removeDependency(taskId: RowId, predecessorId: RowId): GanttActionResult;
updateDependencies(taskId: RowId, dependencies: readonly Dependency[] | string): GanttActionResult;
splitTask(id: RowId, date: GanttDateInput): GanttActionResult;
mergeSegments(id: RowId, segmentIndexes: readonly number[]): GanttActionResult;
convertToMilestone(id: RowId): GanttActionResult;
convertToTask(id: RowId): GanttActionResult;
setTaskMode(id: RowId, mode: 'auto' | 'manual'): GanttActionResult;
setProjectDates(start: GanttDateInput, end: GanttDateInput): void;
expandAll(): void;
collapseAll(): void;
expandRows(ids: RowId | readonly RowId[]): void;
collapseRows(ids: RowId | readonly RowId[]): void;
zoomIn(): void;
zoomOut(): void;
zoomToFit(): void;
getZoom(): number;
extendTimeline(side: 'start' | 'end'): void;
scrollToDate(date: GanttDateInput): void;
scrollToTask(id: RowId): void;
scrollTo(options: {
readonly top?: number;
readonly left?: number;
}): void;
setSplitterPosition(position: number | string): void;
openAddDialog(): void;
openEditDialog(id: RowId): void;
closeDialog(): void;
undo(): void;
redo(): void;
getUndoActions(): readonly string[];
getRedoActions(): readonly string[];
clearUndo(): void;
clearRedo(): void;
setLoading(loading: boolean): void;
getState(): GanttState;
restoreState(state: GanttState): void;
exportToExcel(options?: GanttGridExportOptions<Row> & {
readonly sheetName?: string;
}): Promise<GanttExportFile<Uint8Array> | null>;
exportToCsv(options?: GanttGridExportOptions<Row> & {
readonly separator?: string;
readonly escapeFormulas?: boolean;
}): Promise<GanttExportFile<string> | null>;
exportToPdf(options?: GanttPdfExportOptions<Row>): Promise<GanttExportFile<Uint8Array> | null>;
print(): void;
getTaskbarElement(id: RowId): HTMLElement | null;
getChartElement(): HTMLElement | null;
}
ref; extends the grid pane's DataGridApi.
| Name | Signature | Description |
|---|---|---|
grid | readonly grid: DataGridApi<Row>; | |
getTask | getTask(id: RowId): Row | undefined; | |
getTaskInfo | getTaskInfo(id: RowId): GanttTaskInfo | undefined; | |
getViewRows | getViewRows(): readonly Row[]; | |
getCriticalTasks | getCriticalTasks(): readonly Row[]; | |
formatDuration | formatDuration(id: RowId): string; | |
formatWork | formatWork(id: RowId): string; | |
addTask | addTask(task?: Partial<Row>, options?: {
readonly position?: 'top' | 'bottom' | 'above' | 'below' | 'child';
readonly targetId?: RowId;
}): GanttActionResult; | |
updateTask | updateTask(id: RowId, changes: Partial<Row>): GanttActionResult; | |
deleteTasks | deleteTasks(ids: RowId | readonly RowId[]): GanttActionResult; | |
changeTaskId | changeTaskId(id: RowId, newId: RowId): GanttActionResult; | |
cancelEdit | cancelEdit(): void; | |
indent | indent(ids: RowId | readonly RowId[]): GanttActionResult; | |
outdent | outdent(ids: RowId | readonly RowId[]): GanttActionResult; | |
moveTasks | moveTasks(ids: RowId | readonly RowId[], targetId: RowId, position: 'above' | 'below' | 'child'): GanttActionResult; | |
addDependency | addDependency(taskId: RowId, dependency: Dependency | string): GanttActionResult; | |
removeDependency | removeDependency(taskId: RowId, predecessorId: RowId): GanttActionResult; | |
updateDependencies | updateDependencies(taskId: RowId, dependencies: readonly Dependency[] | string): GanttActionResult; | |
splitTask | splitTask(id: RowId, date: GanttDateInput): GanttActionResult; | |
mergeSegments | mergeSegments(id: RowId, segmentIndexes: readonly number[]): GanttActionResult; | |
convertToMilestone | convertToMilestone(id: RowId): GanttActionResult; | |
convertToTask | convertToTask(id: RowId): GanttActionResult; | |
setTaskMode | setTaskMode(id: RowId, mode: 'auto' | 'manual'): GanttActionResult; | |
setProjectDates | setProjectDates(start: GanttDateInput, end: GanttDateInput): void; | |
expandAll | expandAll(): void; | |
collapseAll | collapseAll(): void; | |
expandRows | expandRows(ids: RowId | readonly RowId[]): void; | |
collapseRows | collapseRows(ids: RowId | readonly RowId[]): void; | |
zoomIn | zoomIn(): void; | |
zoomOut | zoomOut(): void; | |
zoomToFit | zoomToFit(): void; | |
getZoom | getZoom(): number; | |
extendTimeline | extendTimeline(side: 'start' | 'end'): void; | |
scrollToDate | scrollToDate(date: GanttDateInput): void; | |
scrollToTask | scrollToTask(id: RowId): void; | |
scrollTo | scrollTo(options: {
readonly top?: number;
readonly left?: number;
}): void; | |
setSplitterPosition | setSplitterPosition(position: number | string): void; | |
openAddDialog | openAddDialog(): void; | |
openEditDialog | openEditDialog(id: RowId): void; | |
closeDialog | closeDialog(): void; | |
undo | undo(): void; | |
redo | redo(): void; | |
getUndoActions | getUndoActions(): readonly string[]; | |
getRedoActions | getRedoActions(): readonly string[]; | |
clearUndo | clearUndo(): void; | |
clearRedo | clearRedo(): void; | |
setLoading | setLoading(loading: boolean): void; | |
getState | getState(): GanttState; | |
restoreState | restoreState(state: GanttState): void; | |
exportToExcel | exportToExcel(options?: GanttGridExportOptions<Row> & {
readonly sheetName?: string;
}): Promise<GanttExportFile<Uint8Array> | null>; | The grid pane's Excel export with the Data Grid |
exportToCsv | exportToCsv(options?: GanttGridExportOptions<Row> & {
readonly separator?: string;
readonly escapeFormulas?: boolean;
}): Promise<GanttExportFile<string> | null>; | |
exportToPdf | exportToPdf(options?: GanttPdfExportOptions<Row>): Promise<GanttExportFile<Uint8Array> | null>; | |
print | print(): void; | |
getTaskbarElement | getTaskbarElement(id: RowId): HTMLElement | null; | |
getChartElement | getChartElement(): HTMLElement | null; | |
getColumninherited | getColumn: (fieldOrId: string) => CompiledColumn<Row> | undefined; | Leaf column by column id, else the first leaf with that |
getColumnsinherited | getColumns: () => readonly CompiledColumn<Row>[]; | Every leaf column in definition order, including hidden ones. |
getVisibleColumnsinherited | getVisibleColumns: () => readonly CompiledColumn<Row>[]; | Visible leaves in runtime order. |
getHiddenColumnsinherited | getHiddenColumns: () => readonly CompiledColumn<Row>[]; | Leaves hidden at runtime, in definition order. |
getColumnAtinherited | getColumnAt: (index: number) => CompiledColumn<Row> | undefined; | Visible leaf at an index of |
getColumnIndexinherited | getColumnIndex: (fieldOrId: string) => number; | Index of a column in |
showColumnsinherited | showColumns: (fieldsOrIds: string | readonly string[]) => CommandResult; | |
hideColumnsinherited | hideColumns: (fieldsOrIds: string | readonly string[]) => CommandResult; | |
getFilteredRowsinherited | getFilteredRows: () => readonly Row[]; | Rows passing search and every filter, in sort order, across every page,
as raw references. Without the
|
getRowinherited | getRow: (rowId: string) => Row | undefined; | |
getRowIndexinherited | getRowIndex: (rowId: string) => number; | Visible index of a row, or -1. |
getRowIdAtinherited | getRowIdAt: (index: number) => string | undefined; | Row id at a visible index (the inverse of |
getCellinherited | getCell: (rowId: string, field: string) => CellSnapshot | undefined; | |
getDataSourceinherited | getDataSource: () => DataSource<Row>; | |
getPrimaryKeyFieldsinherited | getPrimaryKeyFields: () => readonly string[]; |
|
getColumnFacetinherited | getColumnFacet: (field: string, options?: FacetOptions | undefined) => ColumnFacet | undefined; | Distinct values with counts for checkbox / Excel filters, or undefined without the |
getPageInfoinherited | getPageInfo: () => PageInfo | undefined; | Pager model, or undefined without the |
groupColumninherited | groupColumn: (field: string, index?: number | undefined) => CommandResult; | Needs the |
ungroupColumninherited | ungroupColumn: (field: string) => CommandResult; | |
clearGroupinginherited | clearGrouping: () => CommandResult; | |
toggleGroupinherited | toggleGroup: (group: GroupTarget, expanded?: boolean | undefined) => CommandResult; | Toggles (or sets) one group by row id, path key, or path. |
expandAllGroupsinherited | expandAllGroups: () => CommandResult; | |
collapseAllGroupsinherited | collapseAllGroups: () => CommandResult; | |
getGroupinherited | getGroup: (rowId: string) => GroupRowSnapshot | undefined; | Caption or footer snapshot of a group row id, or undefined. |
getAggregatesinherited | getAggregates: (groupId?: string | undefined) => Readonly<Record<string, Readonly<Record<string, unknown>>>> | undefined; | Without an argument the footer aggregates (undefined without the
|
refreshinherited | refresh: () => void; | Re-reads the data with the current query and keeps the grid state: |
disposeinherited | dispose: () => void; | |
resetStateinherited | resetState: () => RestoreResult; | Restores the state captured when this API was created. |
pinColumninherited | pinColumn: (field: string, pinned: DataGridColumnPin | null) => CommandResult; | Pins a column (id or field) to a side or unpins it ( |
openColumnChooserinherited | openColumnChooser: (position?: { readonly x: number; readonly y: number; } | undefined) => void; | Opens the column chooser; at the given viewport point, else at the grid start. |
openColumnMenuinherited | openColumnMenu: (field: string) => void; | |
openFilterMenuinherited | openFilterMenu: (field: string) => void; | |
closeOverlaysinherited | closeOverlays: () => void; | Closes any open menu, dialog, or chooser (focus returns to its invoker). |
registerCommandHandlerinherited | registerCommandHandler: (command: DataGridUiCommand | (string & {}), handler: DataGridCommandHandler) => () => void; | Registers the handler of a UI command (toolbar, menus); returns the unregister function. |
runCommandinherited | runCommand: (command: DataGridUiCommand | (string & {}), payload?: Readonly<Record<string, unknown>> | undefined) => boolean; | Runs a UI command (handler, then a module command, else a dev warning). Returns true when handled. |
getHeaderElementinherited | getHeaderElement: (field: string) => HTMLElement | null; | Header cell of a column (id or field); |
getPartElementinherited | getPartElement: (part: DataGridPart) => HTMLElement | null; | First rendered element of a part; |
openSortDialoginherited | openSortDialog: () => void; | Opens the sort sheet ( |
openFilterDialoginherited | openFilterDialog: (field?: string | undefined) => void; | Opens the filter sheet of |
isAdaptiveinherited | isAdaptive: () => boolean; | True while the adaptive layout applies (derived from the measured container width). Salmon |
copyinherited | copy: (options?: DataGridCopyOptions | undefined) => CommandResult; | Copies the cell range, else the selected rows, else the focused cell to
the system clipboard (drafts included). Falls back to a copy dialog when
the browser blocks clipboard access. |
pasteinherited | paste: (text?: string | undefined) => CommandResult; | Pastes TSV |
startEditinherited | startEdit: (rowId?: string | undefined, field?: string | undefined) => CommandResult; | Row and dialog mode edit the row, batch and cell mode the cell. Without a row id: the first selected row. |
saveinherited | save: () => CommandResult; | Saves: the active row or cell; in batch mode every pending change. |
saveCellinherited | saveCell: () => CommandResult; | Commits the active editor only (batch mode keeps the change pending). |
addRowinherited | addRow: (row?: Readonly<Record<string, unknown>> | undefined, index?: number | undefined) => CommandResult; | Index 0 adds at the top, at or past the end at the bottom. |
deleteRowsinherited | deleteRows: (rowIds?: string | readonly string[] | undefined) => CommandResult; | Without ids: the selected rows. Batch mode marks the rows until save. |
updateRowinherited | updateRow: (rowId: string, row: Readonly<Record<string, unknown>>) => CommandResult; | |
updateCellinherited | updateCell: (rowId: string, field: string, value: unknown) => CommandResult; | Edits a cell as a user would (draft in batch mode). |
setCellValueinherited | setCellValue: (rowId: string, field: string, value: unknown) => CommandResult; | Silent data updates without the edit lifecycle (local sources). |
setRowDatainherited | setRowData: (rowId: string, row: Row) => CommandResult; | |
applyChangesinherited | applyChanges: (changes: EditDataChanges<Row>) => CommandResult; | |
getPendingChangesinherited | getPendingChanges: () => EditBatchChanges<Row>; | |
getBatchPreviewinherited | getBatchPreview: () => EditPreview | undefined; | |
getEditSnapshotinherited | getEditSnapshot: () => EditSnapshot | undefined; | |
hasUnsavedChangesinherited | hasUnsavedChanges: () => boolean; | |
whenEditSettledinherited | whenEditSettled: () => Promise<void>; | |
validateBatchinherited | validateBatch: () => Promise<boolean>; | Validates every pending change without saving; resolves true when valid. |
fillSelectioninherited | fillSelection: (rowId: string, field: string) => CommandResult; | Fills the selected cell range's content over the range extended to |
sortColumninherited | sortColumn: (field: string, direction: DataGridSortDirection, options?: { multiple?: boolean; } | undefined) => CommandResult; | Sorts by a column; |
removeSortinherited | removeSort: (field: string) => CommandResult; | |
clearSortinginherited | clearSorting: () => CommandResult; | |
filterColumninherited | filterColumn: (field: string, operator: DataGridFilterOperator, value: Json, options?: { logic?: "and" | "or"; matchCase?: boolean; ignoreAccents?: boolean; } | undefined) => CommandResult; | Replaces the column's top-level conditions with one condition (an array value with a scalar operator ORs one condition per value). |
removeFilterinherited | removeFilter: (field: string) => CommandResult; | Removes the filters of one column. |
clearFilteringinherited | clearFiltering: (fields?: string | readonly string[] | undefined) => CommandResult; | Removes the filters of the given columns, or every filter. |
searchinherited | search: (text: string) => CommandResult; | |
clearSearchinherited | clearSearch: () => CommandResult; | |
goToPageinherited | goToPage: (page: number) => CommandResult; | |
setPageSizeinherited | setPageSize: (pageSize: number) => CommandResult; | |
expandDetailinherited | expandDetail: (rowId: string) => CommandResult; | |
collapseDetailinherited | collapseDetail: (rowId: string) => CommandResult; | |
toggleDetailinherited | toggleDetail: (rowId: string, expanded?: boolean | undefined) => CommandResult; | Toggles one detail row; |
expandAllDetailsinherited | expandAllDetails: () => CommandResult; | |
collapseAllDetailsinherited | collapseAllDetails: () => CommandResult; | |
isDetailExpandedinherited | isDetailExpanded: (rowId: string) => boolean; | |
getChildGridinherited | getChildGrid: (rowId: string) => DataGridApi<unknown> | null; | The mounted child grid of a parent row (null when collapsed or not rendered). |
moveRowsinherited | moveRows: (rowIds: string | readonly string[], to: number | DataGridMoveTarget) => CommandResult; | Moves rows so the first one ends at data row index |
expandAllTreeRowsinherited | expandAllTreeRows: () => CommandResult; | |
collapseAllTreeRowsinherited | collapseAllTreeRows: () => CommandResult; | |
expandTreeLevelinherited | expandTreeLevel: (depth: number) => CommandResult; | Expands the parents at |
collapseTreeLevelinherited | collapseTreeLevel: (depth: number) => CommandResult; | |
expandTreeRowsinherited | expandTreeRows: (rowIds: string | readonly string[]) => CommandResult; | |
collapseTreeRowsinherited | collapseTreeRows: (rowIds: string | readonly string[]) => CommandResult; | |
toggleTreeRowinherited | toggleTreeRow: (rowId: string, expanded?: boolean | undefined) => CommandResult; | |
indentRowsinherited | indentRows: (rowIds: string | readonly string[]) => CommandResult; | Moves rows under their previous sibling. |
outdentRowsinherited | outdentRows: (rowIds: string | readonly string[]) => CommandResult; | Moves rows after their parent, as its siblings. |
getTreeRowinherited | getTreeRow: (rowId: string) => DataGridTreeRowInfo | null; | |
getChildRowsinherited | getChildRows: (rowId: string | null) => readonly Row[]; | Kept children of a row in view order ( |
reloadTreeChildreninherited | reloadTreeChildren: (rowId: string) => CommandResult; | Salmon: retries a failed lazy child load. |
getVisibleRowsinherited | getVisibleRows: () => readonly Row[]; | Visible data rows in view order. |
pinRowsinherited | pinRows: (rowIds: string | readonly string[]) => CommandResult; | Pins rows to the top zone (rejected unless |
unpinRowsinherited | unpinRows: (rowIds: string | readonly string[]) => CommandResult; | Unpins rows, also rows |
isRowPinnedinherited | isRowPinned: (rowId: string) => boolean; | True when the row is pinned, whether or not the current filter shows it. |
getPinnedRowIdsinherited | getPinnedRowIds: () => readonly string[]; | Ids of the pinned rows shown, in display order. |
openFilterBuilderinherited | openFilterBuilder: () => void; | Opens the filter builder dialog.
Ignored unless |
closeFilterBuilderinherited | closeFilterBuilder: () => void; | Closes the filter builder dialog without applying. |
getViewportinherited | getViewport: () => DataGridViewport; | Scroll sync extension point: the current body viewport. |
subscribeViewportinherited | subscribeViewport: (listener: () => void) => () => void; | Calls |
getRowOffsetsinherited | getRowOffsets: () => RowMetrics; | Row height extension point: the row offsets of the visible row model (the body's own prefix sums). |
getPageSizeForHeightinherited | getPageSizeForHeight: (height: number) => number; | Whole data rows that fit in |
selectRowsinherited | selectRows: (rowIds: string | readonly string[], options?: { mode?: "add" | "remove" | "replace" | "toggle"; } | undefined) => CommandResult; | |
selectRowRangeinherited | selectRowRange: (fromRowId: string, toRowId: string, options?: { mode?: "add" | "replace"; } | undefined) => CommandResult; | |
selectAllinherited | selectAll: (options?: { scope?: "filtered" | "page"; } | undefined) => CommandResult; |
|
clearSelectioninherited | clearSelection: (parts?: { rows?: boolean; cells?: boolean; columns?: boolean; } | undefined) => CommandResult; | |
selectCellsinherited | selectCells: (cells: readonly DataGridCellKey[], options?: { mode?: "add" | "replace" | "toggle"; } | undefined) => CommandResult; | |
selectCellRangeinherited | selectCellRange: (anchor: DataGridCellKey, focus: DataGridCellKey, options?: { mode?: "add" | "replace"; } | undefined) => CommandResult; | |
selectColumnsinherited | selectColumns: (fields: string | readonly string[], options?: { mode?: "add" | "replace" | "toggle"; } | undefined) => CommandResult; | |
isRowSelectedinherited | isRowSelected: (rowId: string) => boolean; | |
getSelectedRowIdsinherited | getSelectedRowIds: () => readonly string[]; | |
getSelectedRowsinherited | getSelectedRows: () => readonly Row[]; | Raw rows, in the order of |
getSelectedCellsinherited | getSelectedCells: () => readonly DataGridCellKey[]; | |
getSelectedColumnsinherited | getSelectedColumns: () => readonly string[]; | |
getSelectioninherited | getSelection: () => SerializedSelection | undefined; | Serializable selection (scope, ids or excluded ids, cell ranges, columns). |
setSelectioninherited | setSelection: (selection: SerializedSelection) => CommandResult; | |
getSelectionSummaryinherited | getSelectionSummary: () => SelectionSummary | undefined; | |
engineinherited | engine: DataGridApiEngine<Row>; | The engine, with the façades of the optional modules a prop registers ( |
elementinherited | element: HTMLDivElement | null; | The root element; null before mount and after unmount. |
focusinherited | focus: () => void; | Focuses the grid content: the focused body cell, else the last focused body cell, else the first body cell (also from the header, like Alt+W). |
focusCellinherited | focusCell: (rowId: string, field: string) => void; | Scrolls the cell into view and focuses it. |
focusHeaderinherited | focusHeader: (field: string) => void; | |
getFocusedCellinherited | getFocusedCell: () => DataGridFocusedCell | null; | |
registerKeyHandlerinherited | registerKeyHandler: (command: string, handler: DataGridKeyHandler, options?: { priority?: number; } | undefined) => () => void; | Registers a handler for a keyboard command ( |
getRowInfoinherited | getRowInfo: (target: string | Element | EventTarget | null) => DataGridRowInfo<Row> | undefined; | Row info by row id, or by any element inside a row (cell, custom template content). |
getRowElementinherited | getRowElement: (rowId: string) => HTMLElement | null; | |
getCellElementinherited | getCellElement: (rowId: string, field: string) => HTMLElement | null; | |
scrollToRowinherited | scrollToRow: (rowId: string, options?: DataGridScrollOptions | undefined) => void; | |
scrollToColumninherited | scrollToColumn: (field: string, options?: DataGridScrollOptions | undefined) => void; | |
autoSizeColumnsinherited | autoSizeColumns: (fields?: string | readonly string[] | undefined) => void; | Fits widths to header and rendered content; every visible column when omitted. |
setColumnWidthinherited | setColumnWidth: (field: string, width: number) => CommandResult; | |
moveColumninherited | moveColumn: (field: string, toIndex: number) => CommandResult; | |
getRenderedRangeinherited | getRenderedRange: () => { readonly rows: VirtualRange; readonly columns: VirtualRange; }; | Rendered row range and center column range (overscan included). |