Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs 4.1 How can I call controller method from a form field

Tags:

extjs4

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
    } 
}
like image 825
Omar Faruq Avatar asked Nov 28 '12 06:11

Omar Faruq


1 Answers

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.

like image 199
Slovo Avatar answered Oct 06 '22 10:10

Slovo