问题描述
是否可以根据商品属性在Dropdown中启用/禁用元素?
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",isDeleted: false },{ title: "Three",isDeleted: false }
],/** What is the expression should I use here? */
choicesVisibleIf: "{item}.isDeleted == false"
}
]};
这里是游乐场:https://plnkr.co/edit/LIp8pZbyXVB3UfBD
谢谢。
解决方法
我认为tt从restFul Api中获取choicesByUrl并在/ getChoices?isDeleted = true .....处添加isDeleted过滤器会更容易,因为无论如何标题和值都是动态的
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"
}
}
]
};