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

5

我正在使用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
    } 
}

感谢VDP的纠正。 - Omar Faruq
1个回答

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”。

它的工作很好。我通过你的代码解决了我的问题。特别感谢Slovo。 - Omar Faruq

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接