extjs4 - Extjs 4.1 如何从表单字段调用 Controller 方法

标签 extjs4

我使用的是 Extjs 4.1。

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

//这是我的 Controller 代码

 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
    } 
}

最佳答案

只需触发事件,例如:

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

作为方法 up 参数,您可以使用“window”等。

关于extjs4 - Extjs 4.1 如何从表单字段调用 Controller 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13598863/

相关文章:

css - 文本 Sprite 样式

javascript - 禁用选中一个复选框组中的复选框或隐藏另一复选框组中具有相同值的复选框

java - 在 ExtJS 中显示

datetime - 如何在 extjs4 网格中设置默认排序列并更改日期格式?

javascript - 如何在网格中的渲染器中获取当前渲染值?

ExtJS 4 - 网格垂直滚动条问题

ExtJs 4 - 在同一网格中拖放

model - Extjs 4.0 商店 - 如何在商店(或模型)中查找字段

javascript - ExtJS 4 - JsonStore + 发布请求的问题

javascript - 创建自定义折叠面板 - Extjs 4.0a2