diff --git a/src/question_multipletext.ts b/src/question_multipletext.ts index 9651afea74..297411f437 100644 --- a/src/question_multipletext.ts +++ b/src/question_multipletext.ts @@ -208,6 +208,15 @@ export class MultipleTextItemModel extends Base public set size(val: number) { this.editor.size = val; } + /** + * An expression used to calculate the [defaultValue](https://surveyjs.io/form-library/documentation/question#defaultValue). + */ + public get defaultValueExpression(): string { + return this.editor.defaultValueExpression; + } + public set defaultValueExpression(val: string) { + this.editor.defaultValueExpression = val; + } /** * The minimum value specified as an expression. For example, `"minValueExpression": "today(-1)"` sets the minimum value to yesterday. */ @@ -805,6 +814,7 @@ Serializer.addClass( name: "requiredErrorText:text", serializationProperty: "locRequiredErrorText", }, + { name: "defaultValueExpression:expression", visible: false }, { name: "minValueExpression:expression", category: "logic", diff --git a/tests/question_multipletexttests.ts b/tests/question_multipletexttests.ts index a004649e88..32c4f66790 100644 --- a/tests/question_multipletexttests.ts +++ b/tests/question_multipletexttests.ts @@ -215,3 +215,29 @@ QUnit.test("min/maxValueExpression executing", (assert) => { q1.items[1].value = 5; assert.equal(q1.items[1].editor.hasErrors(), true); }); +QUnit.test("defaultValueExpression executing", (assert) => { + const survey = new SurveyModel({ + questions: [ + { + type: "multipletext", + name: "q1", + items: [ + { + name: "item1" + }, + { + name: "item2" + }, + { + name: "item3", + defaultValueExpression: "{q1.item1} + {q1.item2}" + } + ] + } + ] + }); + const q1 = survey.getQuestionByName("q1"); + q1.items[0].value = 10; + q1.items[1].value = 5; + assert.equal(q1.items[2].editor.value, 15, "Calculated correctly"); +});