我使用的是 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/