Extjs 4.1如何从表单字段调用控制器方法

时间:2012-11-28 06:08:49

标签: extjs4

我正在使用Extjs 4.1。

如何通过按钮单击操作从已经使用此方法的表单调用控制器方法?我希望这个方法可以从表单字段重用,但我不知道如何做到这一点。

//这是我的控制器代码

 init: function() {
    this.control({            
        'salewindow button[action=resetAll]': {
            click: this.resertform
        }
    });
},

resertform : function(button){       
    var store = Ext.data.StoreManager.get('Items');
    store.destroy();
    var vatstore = Ext.data.StoreManager.get('Vats');
    vatstore.reload();            
}

//这里是来自现场监听器的

{
    xtype         : 'textfield',
    name          : 'BranchId',
    fieldLabel    : 'Branch Id',
    allowNegative : false,
    id            : 'branchid',
    value         : '1',                
    onBlur        : function(){                                        
        restoreItem();// I want to call above controller method from here
    } 
}

1 个答案:

答案 0 :(得分:5)

只需点火事件:

    {
        xtype         : 'textfield',
        name          : 'BranchId',
        fieldLabel    : 'Branch Id',
        allowNegative : false,
        id            : 'branchid',
        value         : '1',                
        onBlur: function(){                                        
            this.up().down('button[action=resetAll]').fireEvent('click');
        } 
    }

作为方法参数,您可以使用'window'作为示例。

相关问题