mardi 18 novembre 2014

Viewcontroller: lookupReference or Ext.ComponentQuery.query

Hi!I'm trying to better understand the viewcontroller.In the following case, I have two components.In the first component i have the 'controller:foo' config, and this component have a button that triggers onAdd function in texfield at the second component (Foo2).In this case I can still use lookupReference (if yes, how) or should be replaced by Ext.ComponentQuery.query?

Code:



Ext.define('MyApp.view.foo.Foo', { extend: 'Ext.panel.Panel', xtype: 'foo', controller: 'foo', tbar: [{ xtype: 'button', text: 'Add', handler: 'onAdd' }]});Ext.define('MyApp.view.foo2.Foo2', { extend: 'Ext.panel.Panel2', xtype: 'foo2', items: [{ xtype: 'textfield', reference: 'footextfieldRef' // itemId: 'footextfielditemId' ... }]});Ext.define('MyApp.view.foo.FooController', { extend: 'Ext.app.ViewController', alias: 'controller.foo', onAdd: function () { var textfield = this.lookupReference('footextfieldRef'); // var textfield = Ext.ComponentQuery.query('#footextfielditemId')[0]; }});

Thanks.



Viewcontroller: lookupReference or Ext.ComponentQuery.query

Aucun commentaire:

Enregistrer un commentaire