Question T1982
Visible to All Users

Set default value to the first row of dynamic matrix

created 6 years ago

[Ticket cloned from T1945: dynamically populating a dropdown selection from a set of user input]

Hi Andrew,

I had a follow-up question related to the matrix dynamic. Is it possible to automatically populate the first line with specified text (e.g., "Top of Resume")?

Thanks!

Answers approved by surveyjs Support

created 6 years ago

You have set the defaultValue of the matrix dynamic. Here is the forked version of your example.

Thank you,
Andrew
SurveyJS Team

    Show previous comments (2)

      Never mind, I got it to work through the survey.setValue function.

        Hi Andrew,

        I'm currently working in this plunker and I'm coming across an issue with the dynamically populated dropdown. It doesn't seem to populate with my two default values unless I trigger it to populate through adding a new section name.

        I'm sure it's the first line in this code:

        JavaScript
        survey.onValueChanged.add(function(sender, options) { var question = options.question; if (!!question && question.getType() == "matrixdynamic") { for (var i = 0; i < question.columns.length; i++) { setChoicesByColumns(sender, question, question.columns[i]); } } });

        Specifically the "onValueChanged" function. Is there another function that would work to support my need?

        Thanks!

          Hello,
          You are setting values before assign the events. Here is the working version.

          Thank you,
          Andrew
          SurveyJS Team