{"record":{"id":"bb3a8a1d4ad0ef10","repo":"slint-ui/slint","slug":"setrowdata-is-not-implemented-on-this-model","errorCode":null,"errorMessage":"setRowData is not implemented on this model","messagePattern":"setRowData is not implemented on this model","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"api/node/typescript/models.ts","lineNumber":134,"sourceCode":"     * Implementations of this function must return the current number of rows.\n     */\n    abstract rowCount(): number;\n    /**\n     * Implementations of this function must return the data at the specified row.\n     * @param row index in range 0..(rowCount() - 1).\n     * @returns undefined if row is out of range otherwise the data.\n     */\n    abstract rowData(row: number): T | undefined;\n\n    /**\n     * Implementations of this function must store the provided data parameter\n     * in the model at the specified row.\n     * The default implementation throws, rejecting the modification.\n     * @param _row index in range 0..(rowCount() - 1).\n     * @param _data new data item to store on the given row index\n     */\n    setRowData(_row: number, _data: T): void {\n        throw new TypeError(\"setRowData is not implemented on this model\");\n    }\n\n    /**\n     * Adds a line to the model with the provided data.\n     * Throws when the model rejects the modification.\n     * The default implementation calls {@link Model.insertRow} with the row count.\n     * @param data new data item to store in a new row.\n     */\n    pushRow(data: T): void {\n        this.insertRow(this.rowCount(), data);\n    }\n\n    /**\n     * Implementations of this function must remove the row at the specified index.\n     * Throws when the model rejects the modification; the default implementation\n     * always throws.\n     * @param _index index of the row to remove.\n     */","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/api/node/typescript/models.ts#L116-L152","documentation":"Base Model's default setRowData throws because a generic model has no way to store data; subclasses must override it to support mutation. The runtime calls this when .slint code assigns to a model row. Throwing rejects the modification loudly instead of silently dropping it.","triggerScenarios":"Slint code (e.g. property assignment on a model row) or JS code calls setRowData(row, data) on a model instance that did not override setRowData.","commonSituations":"Using a read-only custom Model subclass in an editable context (text input bound to model data), forgetting to implement setRowData when making a model two-way editable.","solutions":["Override setRowData(row, data) in your Model subclass to persist the new value.","If the model must be read-only, change the .slint usage so rows are not assigned to.","Switch to ReadOnlyModel/ArrayModel, which implements setRowData over its backing array."],"exampleFix":"// before\nclass MyModel extends slint.Model { rowCount() { return 1; } rowData(i) { return 'x'; } }\n// after\nclass MyModel extends slint.Model {\n  rowCount() { return 1; }\n  rowData(i) { return 'x'; }\n  setRowData(row, data) { this.data[row] = data; }\n}","handlingStrategy":"try-catch","validationCode":"if (model.setRowData === slint.Model.prototype.setRowData) throw new Error('model is read-only');","typeGuard":"function isEditableModel<T>(m: slint.Model<T>): boolean {\n  return m.setRowData !== slint.Model.prototype.setRowData;\n}","tryCatchPattern":"try {\n  model.setRowData(row, value);\n} catch (e) {\n  if (e instanceof TypeError && /setRowData is not implemented/.test(e.message)) {\n    console.warn('model is read-only; change ignored');\n  } else throw e;\n}","preventionTips":["Override setRowData whenever a custom model backs editable UI elements.","Prefer ReadOnlyModel/ArrayModel over hand-rolled Model subclasses.","Document read-only models in your component API."],"tags":["typescript","model","not-implemented"],"backgroundTag":"method-not-implemented","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}