代码之家  ›  专栏  ›  技术社区  ›  jenkelblankel

绑定按钮在Ext JS中不起作用

  •  1
  • jenkelblankel  · 技术社区  · 7 年前

    我想禁用Zulu按钮,直到change函数中的项设置了newVal。目前,Zulu按钮已启用,这是一个问题,因为我希望在特定条件(即项目)之前将其禁用。set('textstuff',newVal);已满足。

    我的代码有什么问题?我用过这个帖子: ExtJS 6 - Bind disabled property to new records in a store 寻求一些灵感,但仍然需要一些帮助。

    title: 'Foo',
                xtype: 'Bar',
                autoSelect: true,
                labelWidth: 150,
                listeners: {
                    change: function(component, newVal, OldVal) {
    
                        var view = this.up('uploadthings');
                        var items = view.getViewModel().getStore('things').data.items;
                        items.forEach(function(item) {
                            item.set('textstuff', newVal);
                        });
                        view.getViewModel('bindBool', true);
                    }
                }
            }, {
    
    
     items: [{
            xtype: 'panel',
            buttons: [{
                style: 'margin-right: 30px',
                text: 'Zulu',
                iconCls: 'x-fa fa-upload',
                handler: 'xray',
                bind: {
                        disabled: '{bindBool}'
                }
            }]
        }]
    
    1 回复  |  直到 7 年前
        1
  •  -1
  •   Leroy    7 年前

    或者在ViewModel中。Js文件您可以添加公式并配置bondbool, 假设您在控制器上设置bindbool: me.getViewModel().set('bindbool', true)

    在ViewModel中:

    formulas : {
        bindbool : {
             get : function(get){
                  var tempVar = get('bindbool'); //--> true because you set it to true
                  return tempVar == true ? tempVar : false;  
            }
        }
    }
    

    通过这样做,您可以控制viewModel输出, 祝您好运,并享受编写Extjs的乐趣