2012-11-28 8 views
5

Sto usando Extjs 4.1.Extjs 4.1 Come posso chiamare il metodo controller da un campo modulo

Come posso chiamare un metodo controller da un modulo che già utilizza questo metodo tramite un'azione di clic del pulsante? Voglio che questo metodo sia riutilizzabile da un campo modulo, ma non so come farlo.

// Ecco il mio codice di controllo

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();    
} 

// e qui è il mio campo da ascoltatore

{ 
    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 
    } 
} 
+0

Grazie VDP per correzione –

risposta

5

Proprio evento fuoco come:

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

Come metodo fino argomento , puoi usare 'finestra' per esempio.

+0

Funziona bene. Risolvo il mio problema con il tuo codice. Grazie speciali Slovo. –

Problemi correlati