Skip to content

Commit

Permalink
The q.getNestedQuestions is not a function exception appears when try…
Browse files Browse the repository at this point in the history
…ing to obtain a list of survey questions (survey.getAllQuestions(false, true, true)) fix #6666 (#6668)
  • Loading branch information
andrewtelnov committed Aug 8, 2023
1 parent 911c33a commit d4088a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5199,6 +5199,7 @@ export class SurveyModel extends SurveyElementCore
includeDesignTime: boolean = false,
includeNested: boolean = false
): Array<Question> {
if(includeNested) includeDesignTime = false;
var res: Array<Question> = [];
for (var i: number = 0; i < this.pages.length; i++) {
this.pages[i].addQuestionsToList(
Expand Down
9 changes: 8 additions & 1 deletion tests/question_matrixdynamictests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1600,14 +1600,15 @@ QUnit.test("matrixDynamic.getNestedQuestions", function (assert) {
const survey = new SurveyModel({
elements: [
{ type: "matrixdynamic", name: "matrix", rowCount: 2,
columns: [{ name: "col1", visibleIf: "{row.col2} = 'a'" }, { name: "col2" }]
columns: [{ name: "col1", cellType: "text", visibleIf: "{row.col2} = 'a'" }, { cellType: "text", name: "col2" }]
}
]
});
const q = <QuestionMatrixDynamicModel>survey.getQuestionByName("matrix");
let questions = q.getNestedQuestions();
assert.equal(questions.length, 4, "4 cells");
assert.equal(questions[0].name, "col1", "cells[0, 0]");
assert.equal(questions[0].getType(), "text", "cells[0, 0]");
assert.equal(questions[1].name, "col2", "cells[0, 1]");
assert.equal(questions[0].name, "col1", "cells[1, 0]");
assert.equal(questions[1].name, "col2", "cells[1, 1]");
Expand All @@ -1621,6 +1622,12 @@ QUnit.test("matrixDynamic.getNestedQuestions", function (assert) {
assert.equal(questions[0].name, "col2", "cells[0, 0], visible");
assert.equal(questions[1].name, "col1", "cells[1, 1], visible");
assert.equal(questions[2].name, "col2", "cells[1, 1], visible");
assert.equal(survey.getAllQuestions().length, 1, "No nested - one question");
assert.equal(survey.getAllQuestions(true, true).length, 1 + 2, "Include design-time + 2 columns");
assert.equal(survey.getAllQuestions(false, false, true).length, 1 + 4, "Include nested + 4 cells");
assert.equal(survey.getAllQuestions(false, true, true).length, 1 + 4, "Include nested + 4 cells, ignore design-time");
assert.equal(survey.getAllQuestions(true, false, true).length, 1 + 3, "Include nested + 3 visible cells");
assert.equal(survey.getAllQuestions(true, true, true).length, 1 + 3, "Include nested + 3 visible cells, ignore design-time");
});
QUnit.test("matrixDynamic.addConditionObjectsByContext + settings.matrixMaxRowCountInCondition=0", function (assert) {
settings.matrixMaxRowCountInCondition = 0;
Expand Down

0 comments on commit d4088a0

Please sign in to comment.