【问题标题】:Surveyjs: choicesVisibleIf based on item propertySurveyjs:choicesVisibleIf 基于项目属性
【发布时间】:2020-08-20 11:11:13
【问题描述】:

是否可以根据项目属性启用/禁用下拉菜单中的元素?

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"
  }
  ]};

这里是游乐场:https://plnkr.co/edit/LIp8pZbyXVB3UfBD

谢谢。

【问题讨论】:

  • 所以你想显示 IsDeleted== false 的选择? choiceVisibleIf 不会这样做.. 这里的表达式 {{Item}} 将意味着不同的问题

标签: surveyjs


【解决方案1】:

在我看来 tt 会更容易从 restFul Api 获取choicesByUrl 并在那里添加一个 isDeleted 过滤器 /getChoices?isDeleted=true .....因为无论如何标题和值都是动态的

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"
                    }
        }
    ]
};

【讨论】:

    猜你喜欢
    • 2012-05-12
    • 2018-10-19
    • 2013-10-11
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 2017-05-14
    • 2015-01-22
    • 2021-11-28
    相关资源
    最近更新 更多