hi,
I got a lot of way of getting a component inside a controller in MVC.
But what is the difference among them.Which is more proper.
like. Ext.widget()
Ext.getCmp()
getComponent()
this.getViewName()
hi,
I got a lot of way of getting a component inside a controller in MVC.
But what is the difference among them.Which is more proper.
like. Ext.widget()
Ext.getCmp()
getComponent()
this.getViewName()
Ext.widget() <- creates generic component
Ext.getCmp() <- get id of component if known; not recommended; use query and itemId
getComponent() <- ok if looking for sub component
this.getViewName() <- MVC approach to get view from config
Scott.
Ext.widget is not a getter. It creates and returns component based on a config rather than the way Ext.create does it.
Ext.getCmp should be avoided as it requires the use of static IDs on a component.
getComponent is fine if you have a reference to the parent of the item you want and know the childs itemId.
this.get____ I am assuming you are referring to using refs to create getters for components. This is generally my preferred way. I find it clean and it also only does the work to find it the first time.
I will occassionaly use down and up as well when a ref might be a little overkill.
If you wanted to get more than one component with your component query you would want to do something like Ext.ComponentQuery.query rather than down/up/refs
--Edit
Sorry for the double answer, I took too long to type that I guess and was beat by a solid 8 minutes.
I started running before the shot was firedI guess and was beat by a solid 8 minutes![]()