{"record":{"id":"d71223daf067eb0b","repo":"slint-ui/slint","slug":"insertrow-is-not-implemented-on-this-model","errorCode":null,"errorMessage":"insertRow is not implemented on this model","messagePattern":"insertRow is not implemented on this model","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"api/node/typescript/models.ts","lineNumber":166,"sourceCode":"     * 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     */\n    removeRow(_index: number): void {\n        throw new TypeError(\"removeRow is not implemented on this model\");\n    }\n\n    /**\n     * Implementations of this function must add a row at the specified index, pushing all next\n     * rows to the right.\n     * Throws when the model rejects the modification; the default implementation\n     * always throws.\n     * @param _index index of the row to insert.\n     * @param _data new data item to store in a new row.\n     */\n    insertRow(_index: number, _data: T): void {\n        throw new TypeError(\"insertRow is not implemented on this model\");\n    }\n\n    [Symbol.iterator](): Iterator<T> {\n        return new ModelIterator(this);\n    }\n\n    /**\n     * Notifies the view that the data of the current row is changed.\n     * @param row index of the changed row.\n     */\n    protected notifyRowDataChanged(row: number): void {\n        napi.jsModelNotifyRowDataChanged(this.modelNotify, row);\n    }\n\n    /**\n     * Notifies the view that multiple rows are added to the model.\n     * @param row index of the first added row.\n     * @param count the number of added items.","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/api/node/typescript/models.ts#L148-L184","documentation":"This is the same not-implemented sentinel as removeRow, thrown by the base Model class when insertRow has not been overridden. It also surfaces indirectly: pushRow's default implementation calls insertRow, so calling pushRow on a subclass that implements neither method lands here. It means the model is effectively read-only unless the subclass adds the insertion hook.","triggerScenarios":"Calling insertRow(index, data) directly, or pushRow(data), on a Model subclass that does not implement insertRow.","commonSituations":"Growing a custom model from JS or .slint (button pushes rows) while the subclass was written read-only.","solutions":["Override insertRow(index, data), mutate storage, then call rowInserted(index).","Use ArrayModel/ReadOnlyModel's pushRow instead of a bare custom Model.","Switch the property binding to an ArrayModel backed by your array."],"exampleFix":"// before\nclass M extends slint.Model { rowCount() { return this.items.length; } }\n// after\nclass M extends slint.Model {\n  insertRow(index, data) { this.items.splice(index, 0, data); this.rowInserted(index); }\n}","handlingStrategy":"try-catch","validationCode":"if (model.insertRow === slint.Model.prototype.insertRow) throw new Error('model cannot insert rows');","typeGuard":"function supportsInsertRow<T>(m: slint.Model<T>): boolean {\n  return m.insertRow !== slint.Model.prototype.insertRow;\n}","tryCatchPattern":"try {\n  model.pushRow(item);\n} catch (e) {\n  if (e instanceof TypeError && /insertRow is not implemented/.test(e.message)) {\n    console.warn('row insertion unsupported by this model');\n  } else throw e;\n}","preventionTips":["Override insertRow in models that will grow at runtime.","Use ArrayModel.pushRow for append-heavy use cases.","Unit-test custom models for insert/remove before wiring UI."],"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"}