Skip to content

FilterModel

Defined in: api/node/typescript/models.ts:431

FilterModel provides a filtered view of rows from a source model, by applying a filter function to each row of the source model. Only rows for which the filter function returns true are visible in the FilterModel.

Note that the FilterModel does not automatically observe modifications made directly to the source model (for example calling ArrayModel.push or ArrayModel.splice on the underlying source model). After such a modification, call FilterModel.reset to re-apply the filter function and refresh the filtered view. Modifications made through FilterModel.setRowData are reflected automatically.

Calling FilterModel.setRowData while the cached mapping is stale (i.e. after the source model was mutated directly without a following FilterModel.reset) does not just return stale reads — it writes to whatever source row the stale mapping points at, which may no longer be the row the caller intended. Always call FilterModel.reset after a direct source mutation before calling FilterModel.setRowData again.

const source = new ArrayModel([1, 2, 3, 4, 5, 6]);
const evenNumbers = new FilterModel(source, (x) => x % 2 === 0);
// prints 2, 4, 6
for (const x of evenNumbers) {
console.log(x);
}
js

T

new FilterModel<T>(sourceModel, filterFunction): FilterModel<T>

Defined in: api/node/typescript/models.ts:445

Constructs a new FilterModel that provides a filtered view on the given sourceModel by applying filterFunction on each of its rows.

Model<T>

the wrapped model.

(data) => boolean

returns true if a row should be visible in the FilterModel.

FilterModel<T>

Model<T>.constructor

readonly sourceModel: Model<T>

Defined in: api/node/typescript/models.ts:435

The source model that this FilterModel filters rows from.

[iterator](): Iterator<T>

Defined in: api/node/typescript/models.ts:196

Iterator<T>

Model.[iterator]


filter(filterFunction): FilterModel<T>

Defined in: api/node/typescript/models.ts:118

Returns a new Model that only contains the rows of this model for which filterFunction returns true.

(data) => boolean

returns true if a row should be visible.

FilterModel<T>

a new FilterModel that wraps the current model.

Model.filter


insertRow(_index, _data): void

Defined in: api/node/typescript/models.ts:190

Implementations of this function must add a row at the specified index, pushing all next rows to the right.

number

index of the row to insert.

T

new data item to store in a new row.

void

Model.insertRow


map<U>(mapFunction): MapModel<T, U>

Defined in: api/node/typescript/models.ts:108

Returns a new Model where all elements are mapped by the function mapFunction.

U

(data) => U

maps the data from T to U.

MapModel<T, U>

a new MapModel that wraps the current model.

Model.map


pushRow(_data): void

Defined in: api/node/typescript/models.ts:168

Implementations of this function must add a line to the model with the provided data.

T

new data item to store in a new row.

void

Model.pushRow


removeRow(_index): void

Defined in: api/node/typescript/models.ts:178

Implementations of this function must remove the row at the specified index.

number

index of the row to remove.

void

Model.removeRow


reset(): void

Defined in: api/node/typescript/models.ts:520

Re-applies the filter function on each row of the source model and notifies the run-time that the filtered view has changed. Call this after modifying the source model directly, so that the filtered view reflects the current state of the source model.

void


reverse(): ReverseModel<T>

Defined in: api/node/typescript/models.ts:137

Returns a new Model with the same rows as this model, in reverse order.

ReverseModel<T>

a new ReverseModel that wraps the current model.

Model.reverse


rowCount(): number

Defined in: api/node/typescript/models.ts:468

Returns the number of entries in the filtered model.

number

Model.rowCount


rowData(row): T | undefined

Defined in: api/node/typescript/models.ts:477

Returns the data at the specified row.

number

index in range 0..(rowCount() - 1).

T | undefined

undefined if row is out of range otherwise the data.

Model.rowData


setRowData(row, data): void

Defined in: api/node/typescript/models.ts:498

Stores the given data in the source model at the row that corresponds to the given filtered row index, then re-reads it from the source model to decide whether it still passes the filter, notifying either a row change or a row removal accordingly.

If the source model’s setRowData does not synchronously commit the value read back by rowData (for example a read-only model that ignores the write), the cached mapping may go out of sync; call FilterModel.reset in that case.

number

index in range 0..(rowCount() - 1).

T

new data item to store on the given row index.

void

Model.setRowData


sort(compareFunction): SortModel<T>

Defined in: api/node/typescript/models.ts:129

Returns a new Model with the same rows as this model, ordered according to compareFunction.

(a, b) => number

compares two rows the same way the callback passed to Array.prototype.sort does.

SortModel<T>

a new SortModel that wraps the current model.

Model.sort


unfilteredRow(filteredRow): number | undefined

Defined in: api/node/typescript/models.ts:531

Given a filteredRow index into this FilterModel, returns the corresponding row index in the source model.

number

index in range 0..(rowCount() - 1).

number | undefined

undefined if filteredRow is out of range otherwise the source row index.


© 2026 SixtyFPS GmbH