[Question] Is it possible to applied "isRequired" to all rows in the matrix? The current behavior is that the error message only prompts out when I have answer no question in the matrix. If I have answer any of the question, the error message would not prompt out.
What should I do if I want to mark all rows of the matrix as mandatory question? Thanks!
I'd use valitation event as shown in this example. I've created a plunk with the following code responsible for matrix question validation checking all rows are answered:
function surveyValidateQuestion(s, options) {
if (options.name === 'Quality') {
var question = s.getQuestionByName("Quality");
if(!question.rows.every(function(row) { return (options.value || {})[row.itemValue] !== undefined; })) {
options.error = "All rows should be answered.";
}
}
}
$("#surveyElement").Survey({
model: model,
onValidateQuestion: surveyValidateQuestion
});
@nadialo If you are talking about Matrix question with radio groups, then we will add a new property to handle this scenario without writing the code: https://github.com/surveyjs/surveyjs/issues/512
If you are taking about matrix dynamic/dropdown, then simple set isRequired to column(s) and all rows become required.
Thank you,
Andrew
@andrewtelnov yes, #512 is exactly what I need. Will it be implemented in the near future? or else, I can implement the work around first.
Thanks a lot!!
@nadialo There is already an option matrix.isAllRowRequired boolean, false by default.
Thank you,
Andrew
Most helpful comment
@nadialo There is already an option matrix.isAllRowRequired boolean, false by default.
Thank you,
Andrew