Canvas Toolkit
← Class index

CSortFilterProxyModel

Models and views · extends CAbstractProxyModel

Provides sorting and text filtering for flat item models.

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

Declared members

rowCount(parent?: CModelIndex): number;

Returns the number of accepted source rows.

columnCount(parent?: CModelIndex): number;

Returns the source model's column count.

mapToSource(proxyIndex: CModelIndex): CModelIndex;

Maps a proxy index to its source-model index.

mapFromSource(sourceIndex: CModelIndex): CModelIndex;

Maps a source index to its proxy-model index.

filterFixedString(): string;

Returns the fixed string used for filtering.

setFilterFixedString(value: string): void;

Sets the fixed string used for filtering.

filterKeyColumn(): number;

Returns the filtered column, or `-1` for all columns.

setFilterKeyColumn(column: number): void;

Sets the filtered column, or `-1` for all columns.

isFilterCaseSensitive(): boolean;

Returns whether fixed-string filtering is case-sensitive.

setFilterCaseSensitive(caseSensitive: boolean): void;

Sets whether fixed-string filtering is case-sensitive.

isSortCaseSensitive(): boolean;

Returns whether text sorting is case-sensitive.

setSortCaseSensitive(caseSensitive: boolean): void;

Sets whether text sorting is case-sensitive.

sortColumn(): number;

Returns the active sort column, or `-1` when unsorted.

sortOrder(): CSortOrder;

Returns the active sort order.

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

Sorts proxy rows without changing the source model.

dynamicSortFilter(): boolean;

Returns whether source data changes automatically rebuild the proxy.

setDynamicSortFilter(enabled: boolean): void;

Sets whether source data changes automatically rebuild the proxy.

invalidate(): void;

Rebuilds the row mapping and resets the proxy.

protected filterAcceptsRow(sourceRow: number): boolean;

Returns whether a source row passes the current filter.

protected lessThan(left: CModelIndex, right: CModelIndex): boolean;

Returns whether the left source index sorts before the right one.

protected sourceModelChanged(_oldSourceModel: CAbstractItemModel | null, _newSourceModel: CAbstractItemModel | null): void;

Rebuilds the mapping after the source model changes.

protected sourceDataChanged(topLeft: CModelIndex, bottomRight: CModelIndex): void;

Updates filtering and sorting after source data changes.

protected sourceModelReset(): void;

Rebuilds the mapping after a source reset.

protected sourceLayoutChanged(): void;

Rebuilds the mapping after a source layout change.

headerData(section: number, orientation: COrientation): string | number | null;

Maps vertical headers to their source rows.