Survey-library: Matrix- "isRequired" not working for all sub-question

Created on 24 Jul 2017  路  4Comments  路  Source: surveyjs/survey-library

[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!

  • browser: Chrome, IE
  • browser version: Chrome Version 59.0.3071.115; IE 11
  • surveyjs platform: jquery
  • surveyjs version: 0.12.20
question

Most helpful comment

@nadialo There is already an option matrix.isAllRowRequired boolean, false by default.

Thank you,
Andrew

All 4 comments

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

Was this page helpful?
0 / 5 - 0 ratings