Model
Defined in: api/node/typescript/models.ts:90 ↗
Model.slint views.
A model is organized like a table with rows of data. The fields of the data type T behave like columns.
Extended by
Section titled “Extended by”Type Parameters
Section titled “Type Parameters”T
the type of the model’s items.
Example
Section titled “Example”As an example let’s see the implementation of ArrayModel
export class ArrayModel<T> extends Model<T> { private a: Array<T>
constructor(arr: Array<T>) { super(); this.a = arr; }
rowCount() { return this.a.length; }
rowData(row: number) { return this.a[row]; }
setRowData(row: number, data: T) { this.a[row] = data; this.notifyRowDataChanged(row); }
push(...values: T[]) { let size = this.a.length; Array.prototype.push.apply(this.a, values); this.notifyRowAdded(size, arguments.length); }
remove(index: number, size: number) { let r = this.a.splice(index, size); this.notifyRowRemoved(index, size); }
get length(): number { return this.a.length; }
values(): IterableIterator<T> { return this.a.values(); }
entries(): IterableIterator<[number, T]> { return this.a.entries() }}Implements
Section titled “Implements”Iterable<T>
Methods
Section titled “Methods”[iterator]()
Section titled “[iterator]()”[iterator]():
Iterator<T>
Defined in: api/node/typescript/models.ts:169 ↗
Returns
Section titled “Returns”Iterator<T>
Implementation of
Section titled “Implementation of”Iterable.[iterator]
insertRow()
Section titled “insertRow()”insertRow(
_index,_data):void
Defined in: api/node/typescript/models.ts:165 ↗
Implementations of this function must add a row at the specified index, pushing all next rows to the right. Throws when the model rejects the modification; the default implementation always throws.
Parameters
Section titled “Parameters”_index
Section titled “_index”number
index of the row to insert.
T
new data item to store in a new row.
Returns
Section titled “Returns”void
pushRow()
Section titled “pushRow()”pushRow(
data):void
Defined in: api/node/typescript/models.ts:143 ↗
Adds a line to the model with the provided data. Throws when the model rejects the modification. The default implementation calls Model.insertRow with the row count.
Parameters
Section titled “Parameters”T
new data item to store in a new row.
Returns
Section titled “Returns”void
removeRow()
Section titled “removeRow()”removeRow(
_index):void
Defined in: api/node/typescript/models.ts:153 ↗
Implementations of this function must remove the row at the specified index. Throws when the model rejects the modification; the default implementation always throws.
Parameters
Section titled “Parameters”_index
Section titled “_index”number
index of the row to remove.
Returns
Section titled “Returns”void
rowCount()
Section titled “rowCount()”
abstractrowCount():number
Defined in: api/node/typescript/models.ts:118 ↗
Implementations of this function must return the current number of rows.
Returns
Section titled “Returns”number
rowData()
Section titled “rowData()”
abstractrowData(row):T|undefined
Defined in: api/node/typescript/models.ts:124 ↗
Implementations of this function must return the data at the specified row.
Parameters
Section titled “Parameters”number
index in range 0..(rowCount() - 1).
Returns
Section titled “Returns”T | undefined
undefined if row is out of range otherwise the data.
setRowData()
Section titled “setRowData()”setRowData(
_row,_data):void
Defined in: api/node/typescript/models.ts:133 ↗
Implementations of this function must store the provided data parameter in the model at the specified row. The default implementation throws, rejecting the modification.
Parameters
Section titled “Parameters”number
index in range 0..(rowCount() - 1).
T
new data item to store on the given row index
Returns
Section titled “Returns”void
© 2026 SixtyFPS GmbH