1

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

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.

  • so you want to show choices which are IsDeleted== false ? choicesVisibleIf won't do that it .. the expression {{Item}} here would means a different question – Rohit Kumar Aug 23 '20 at 08:10

1 Answers1

0

in my opinion tt would be easier to get choicesByUrl from a restFul Api & add an isDeleted Filter there /getChoices?isDeleted=true .....because anyway the title & value is going to by dynamic

var json = {
    questions: [
        {
            type: "dropdown",
            name: "car",
            title: "What car are you driving?",
            isRequired: true,
            colCount: 0,
            choicesByUrl: {
                        url: "https://getChoices/rest/v2?isDeleted=false",
                        valueName: "title"
                    }
        }
    ]
};
Rohit Kumar
  • 1,777
  • 2
  • 13
  • 26