kelv1n
20 Nov 2011, 4:00 PM
Hi Guys
I'm new to ExtJS, I wrote a basic top-down app, which I'm now converting to the ExtJS MVC. The conversion is going well, but I cannot figure out the best way to access controls defined in specific views.
Basically, I have a Toolbar View which has 2 date fields, couple Combo Boxes and a couple of buttons directly defined in it (i.e. they are not seperate views).
What I need to know, what is the best way to access these individual controls so I can manipulate then? (get and set values etc).
I've found a couple of options, but every article I read says this bad practise -
Solution 1 - Use Ext.getCmp()
Solution 2 - In the controller use this.getToolbar().getComponent('fromdate')
Solution 3 - Use the Ext.ComponentQuery.query()
I used these originally in my top-down script, and I'm converting to MVC to try and avoid these. Also I ran into some problems using getComponent() as I believe it required an ID to be set for each component, which caused errors when the same View was re-used, the reason for this is understandable (2 components/controls with the same id is recipe for disaster).
Could anybody tell me the best practise way of doing this? Perhaps tell me what attribute need to be set in the Combo components and what function to call in the controller to get access to the control?
Thanks
I'm new to ExtJS, I wrote a basic top-down app, which I'm now converting to the ExtJS MVC. The conversion is going well, but I cannot figure out the best way to access controls defined in specific views.
Basically, I have a Toolbar View which has 2 date fields, couple Combo Boxes and a couple of buttons directly defined in it (i.e. they are not seperate views).
What I need to know, what is the best way to access these individual controls so I can manipulate then? (get and set values etc).
I've found a couple of options, but every article I read says this bad practise -
Solution 1 - Use Ext.getCmp()
Solution 2 - In the controller use this.getToolbar().getComponent('fromdate')
Solution 3 - Use the Ext.ComponentQuery.query()
I used these originally in my top-down script, and I'm converting to MVC to try and avoid these. Also I ran into some problems using getComponent() as I believe it required an ID to be set for each component, which caused errors when the same View was re-used, the reason for this is understandable (2 components/controls with the same id is recipe for disaster).
Could anybody tell me the best practise way of doing this? Perhaps tell me what attribute need to be set in the Combo components and what function to call in the controller to get access to the control?
Thanks