diff --git a/src/question_matrix.ts b/src/question_matrix.ts index 684ed784a7..1696a90b7a 100644 --- a/src/question_matrix.ts +++ b/src/question_matrix.ts @@ -35,7 +35,7 @@ export class MatrixRowModel extends Base { ) { super(); this.data = data; - this.value = value; + this.setValueDirectly(value); this.cellClick = (column: any) => { this.value = column.value; }; diff --git a/tests/surveyquestiontests.ts b/tests/surveyquestiontests.ts index c59cf676ba..d67646b966 100644 --- a/tests/surveyquestiontests.ts +++ b/tests/surveyquestiontests.ts @@ -7560,3 +7560,15 @@ QUnit.test("Hide errors on making question disabled", function (assert) { assert.equal(q2.isReadOnly, true, "q2 is read-only"); assert.equal(q2.errors.length, 0, "Clear errors on making questio read-only"); }); +QUnit.test("matrix.visibleRows and read-only", function (assert) { + const survey = new SurveyModel({ + elements: [ + { type: "matrix", name: "matrix", columns: ["col1", "col2"], rows: ["row1", "row2"], readOnly: true } + ] + }); + const matrix = survey.getQuestionByName("matrix"); + matrix.value = { row1: "col1", row2: "col2" }; + assert.equal(matrix.visibleRows.length, 2, "visibleRows.length"); + assert.equal(matrix.visibleRows[0].value, "col1", "row1.value"); + assert.equal(matrix.visibleRows[1].value, "col2", "row2.value"); +});