Canvas Toolkit
← Class index

CTableView

Widgets · extends CAbstractItemView

Implements the table view widget.

import { CTableView } from "canvas-toolkit-lib";

Declared members

static readonly RowHeight = 24;
static readonly ColumnWidth = 120;
selectionMode(): CTableSelectionMode;
setSelectionMode(mode: CTableSelectionMode): void;
constructor(parent?: CWidget | null);

Creates a new instance.

visualRect(index: CModelIndex): CRect;

Returns the item rectangle in content-widget coordinates.

horizontalHeader(): CHeaderView;

Provides horizontal header behavior.

verticalHeader(): CHeaderView;

Provides vertical header behavior.

isSortingEnabled(): boolean;

Returns whether sorting by clicking the header is enabled.

setSortingEnabled(enabled: boolean): void;

Enables or disables sorting by clicking the horizontal header.

sortByColumn(column: number, order?: CSortOrder): void;

Sorts the model by the requested column and order.

viewport(): CWidget;

Provides viewport behavior.

horizontalScrollBar(): CScrollBar;

Provides horizontal scroll bar behavior.

verticalScrollBar(): CScrollBar;

Provides vertical scroll bar behavior.

scrollX(): number;

Provides scroll x behavior.

scrollY(): number;

Provides scroll y behavior.

setScrollX(x: number): void;

Sets the scroll x.

setScrollY(y: number): void;

Sets the scroll y.

scrollTo(x: number, y: number): void;

Provides scroll to behavior.

sizeHint(): CSize;

Returns the preferred size of the widget.

setGeometry(x: number, y: number, width: number, height: number): void;

Sets the geometry.

resize(width: number, height: number): void;

Provides resize behavior.

paintCells(painter: CPainter): void;

Provides paint cells behavior.

contentMouseMoveEvent(event: CMouseEvent): void;

Updates the range only while the corner gesture owns pointer capture.

contentMouseReleaseEvent(event: CMouseEvent): void;
contentMouseLeaveEvent(): void;
contentMousePressEvent(event: CMouseEvent): void;

Handles the content mouse press event.

contentMouseDoubleClickEvent(event: CMouseEvent): void;

Starts editing the cell under a double click.

protected contextMenuEvent(event: CContextMenuEvent): void;
destroy(): void;
protected contextCellActions(): {
        enabled: boolean;
        cut: () => void;
        clear: () => void;
    } | null;

Supplies model-specific Cut and Clear actions, if available.

readonly pasteRejected: CSignal<[row: number, column: number, message: string]>;

Reports the rejected destination and reason when a paste cannot be applied.

canPaste(): boolean;
paste(text?: string): void;

Pastes text at the current cell through the model's atomic edit API.

canCopy(): boolean;

Returns whether the table has cells to copy.

selectedText(): string;

Serializes the selected cells in view order as tab-separated text.

copy(text?: string): void;

Copies selected cells to the clipboard.

undo(): void;

Undoes the most recent model edit when the model provides history.

redo(): void;

Reapplies the most recently undone model edit.

contentKeyPressEvent(event: CKeyEvent): void;

Handles the content key press event.

protected editorParent(): CWidget;

Returns the widget used as editor parent.

protected modelChanged(_oldModel: CAbstractItemModel | null, newModel: CAbstractItemModel | null): void;

Updates table-specific state after a model change.

protected modelDataChanged(): void;

Repaints table cells after model data changes.

protected modelReset(): void;

Updates table geometry and headers after a model reset.

protected modelLayoutChanged(): void;

Updates table geometry after rows are rearranged or filtered.

protected modelRowsInserted(_parent: CModelIndex, _first: number, _last: number): void;

Updates table geometry after rows are inserted.

protected modelRowsRemoved(_parent: CModelIndex, _first: number, _last: number): void;

Updates table geometry after rows are removed.

protected currentIndexChanged(index: CModelIndex): void;

Scrolls to and repaints a newly selected current index.

protected editorClosed(): void;

Restores focus to the table content after editing.