Question T8431
Visible to All Users

How to get all drop-down questions?

created 3 years ago

Hi,
We have requirement like, need to update all the drop-down choices
2021-12-23_151734.png

How to get all drop-down questions so we can iterate and update the choices. similar to survey.getAllPanels()

I have tried to set "question.choices" property. but we need generic function.

TypeScript
survey.getQuestionByName('dropdown1').choices = [ 'Ford', 'Vauxhall' ];

Answers approved by surveyjs Support

created 3 years ago

Hello,
Every SurveyJS object has getType(): string function. Question dropdown getType() function returns "dropdown".
You can get all questions survey.getAllQuestions() and filter them using getType() function.

Thank you,
Andrew
SurveyJS Team

    Comments (2)

      Hello,
      For dropdown inside Matric (dynamic rows)/ Panel (dynamic panels)?

        matrices has columns and a column has "cellType" property and "choices" property and dynamic panel has templateElements array - the list of elements inside the template panel. It is used to generate panel dynamically.
        You can use marix.columns (cellType/choices) and panelDynamic.templateElements arrays.

        If you want to access generated instances in rows and panels, then it is another story.

        Thank you,
        Andrew
        SurveyJS Team