extjs - 在绑定(bind) View 中应用条件

如何在绑定(bind)中应用条件?

鉴于让
{ xtype : 'label', bind : { text : '{//--- set text as per the condition }', hidden : '{//should be true if 'param' in VM is 1 or 2 else should be false}' } }
在 View 模型中,'param' 是一个数据变量。如果值为

param=1, text 应该是 1,

param=2,文本应该是两个,

param=3,文本应该是三个。

通过直接在 View 中应用条件,这是否可能没有公式?

最佳答案

{
    xtype : 'label',
    bind : 
    {
        text : '{textVal}'==0?'Test':'TEST1234',
        hidden : ('{param}'==1 || '{param}'==2)?true:false
    }
}

在关联的 viewModel 中,如果有属性 param在数据配置中,可以将其用于绑定(bind)以及如上所述的条件检查。如果 param值正在动态更改,(即 this.getViewModel().setData('param', 1)) 然后代码仍然可以动态隐藏组件。这同样适用于其他配置 viewModel -> data:{textVal:0,param:1} 。如果数据中有一个对象,例如 data:{ config:{ textVal:0 }, param:1 } ,可以使用bind:{ text:'{config.textVal}' //along with ur condition check }

https://stackoverflow.com/questions/27980734/

相关文章:

node.js - 为什么 bcryptjs 在 AWS Lambda 上比在本地 docker 上

python - 如何在 Python 的特定范围内替换数据框中的数字?

macos - undefined symbol : "boost::system::generic

visual-studio-code - 如何在 visual studio 代码中显示完整的长行(

forms - 如何使用 cakephp 和 twitter bootstrap 在 poSTLin

macos - 检查签名工具失败并显示消息 : resource envelope is obsol

perl - Perl 中的并行计算

proxy - JProfiler - 有防火墙时如何配置远程应用程序?

maven - Intellij IDEA 不更新 pom.xml 文件

visual-studio-2015 - IApplicationBuilder 不包含 UseWe