Question T4997
Visible to All Users

choicesVisibleIf based on item property

created 4 years ago

Hello!
Is it possible to enable/disable element in Dropdown based on item properties?

JavaScript
var json = { questions: [ { type: "dropdown", name: "car", title: "What car are you driving?", isRequired: true, colCount: 0, choices: [ { title: "One", value: "91", isDeleted: true }, { title: "Two", value: "91", isDeleted: false }, { title: "Three", value: "91", isDeleted: false } ], /** What is the expression should I use here? */ choicesVisibleIf: "{item}.isDeleted == false" } ]};

Here is a playground: https://plnkr.co/edit/LIp8pZbyXVB3UfBD
Thanks.

Comments (2)
A A
Advaita Krishna dasa 4 years ago

    Thanks, Serge for your answer.

    Is it possible to assign custom properties like this?

    Code
    question.choices = myDictionary.map(x => ({ value: x.Id, text: x.Name, isDeleted: x.IsDeleted }));

    Looks like isDeleted just ignored.

      Hello,

      In this case you need to set custom properties separately.

      Thanks, Serge
      SurveyJS Team

      Answers approved by surveyjs Support

      created 4 years ago

      Hello,

      Yes. Here is the updated plunker - https://plnkr.co/edit/gngYxYkdq1PTZ0cc

      Thanks, Serge
      SurveyJS Team