Hi Team,
Master data dropdown choices are showing as undefined after deleting dynamic matrix row, and that is reason for All country name this expression is not working =>
expression: "concatInArray('Static panel Question', 'Column 1',';')",
Can you please have a look? Sharing sample demo, Here Dynamic matrix First column is master dropdown and value of 'All country name ' depends on this master dropdown column and on delete of dynamic matrix row, 'All country name ' is getting empty, as we have choice coming as undefined!
Hi Santosh,
I suppose that the
concatInArray
is a custom function. However, I cannot locate the corresponding code in the provided demo. Would you please share the code of a customconcatInArray
function?export function concatInArrayInternal(question, columnName, sep?) { if (question.getVisibleRows() && question.getVisibleRows().length) { const filteredQuestions = question.getVisibleRows().reduce((acc, row) => { acc.push( ...(row.questions && row.questions.length ? [ ...row.questions.filter( (q) => q && q.name === columnName && !!q.value ), ] : []) ); return acc; }, []); const result = getCombinedQuestionValues(filteredQuestions); const separator = getSeparator(sep); return result.join(separator); } }
FunctionFactory.Instance.register("concatInArray", function ([quesName, childName, separator]) { if (!isSurveyRendered) return this.question?.value; const question = this.survey?.findQuestionByName(quesName) as Question; // HERE IN THIS QUESTION ITSELF WE ARE GETTING CHOICES EMPTY FOR MATRIX COLUMNS if (question && question.getType() === 'matrixdynamic') { return concatInArrayInternal(question, childName, separator); } else if (question && question.getType() === 'paneldynamic') { return concatInPanelInternal(question, childName, separator); } else { return ''; } });
any update on this?
Hello Santosh,
In the code you gave us there is no
getCombinedQuestionValues
andgetSeparator
functions. As result we can't compile your code.Further, we don't have
masterdata_dropdown
question type and in the demo the cell question renders as a "text" questionCould you please provide an example that generates the error? We can't find the reason of the error if we can't reproduce this error.
Thank you,
Andrew
SurveyJS Team
Hi Andrew,
Can you just help us understand after deleting dynamic matrix row, why choices are getting empty for matrix column =>
const question = this.survey?.findQuestionByName(quesName) as Question;
Problem will get resolved automatically, if we get this!
Hello Santosh,
I am sorry, are you trying to get the cell question using
this.survey?.findQuestionByName(quesName)
code? This function will return a top level question only.To get the cell you will need to write a function that will pass (1) question name (matrix), (2) column name, (3) row visible index (number).
function getCellQuestion(questionName: string, columName: string, rowIndex: number): Question { const matrix = this.survey.getQuestionByName(questionName); if(!matrix || !Array.isArray(matrix.visibleRows)) return null; const rows = matrix.visibleRows; if(rowIndex < 0 || rowIndex >= rows.length) return null; return rows[rowIndex].getQuestionByName(columnName); }
I did not try this function, but it should work.
Thank you,
Andrew
SurveyJS Team