I'm using Extjs 4.1.
How can I call a controller method from a form that is already using this method through a button click action? I want this method to be reusable from a form field, but I don't know how to do this.
// here is my controller code
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();
}
//and here is my from field listener
{
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
}
}
Just fire event like:
{
xtype : 'textfield',
name : 'BranchId',
fieldLabel : 'Branch Id',
allowNegative : false,
id : 'branchid',
value : '1',
onBlur: function(){
this.up().down('button[action=resetAll]').fireEvent('click');
}
}
As method up argument, you can use 'window' for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With