View Full Version : newbie questing

3 May 2011, 4:10 AM
Hi everybody!
I'm a newbie at ExtJS. I'm currently reading "Learning Ext JS 3.2", during this book we wrote a simple app located in one file. Everything was perfect untill I tryied to use Ext designer which using another pattern - many classes which extends basic components. I can't figure out how to access this components.

For example I have an viewport with tabpanel on one region and button on another. And I want to access or create new tab by pressing button. If tabpanel is created by var x = new Ext.Tabpanel.... I can access it by this var name - X.
Can anybody tell me how to access components which were generated using designer, when everything I have is componentsUi, components files and the only "var" I have is the root app name???

Tim Toady
3 May 2011, 12:43 PM
There are a number of ways. The easiest way would be the function Ext.getCmp() which you pass an id property that you specified on a component. Ids must be unique or you will have problems. I usually try to avoid it except in testing.

You can also get a component relative to another component using itemId, ref, or navigating around with ownerCt (for the parent) or the items array (children).

See the id, itemId, and ref config options in the api. It provides examples.


BTW nothing is stopping you from pulling apart generated code either! Though you should be able to access other component without doing so.

3 May 2011, 6:47 PM
you should design your app with relation or structure.
if there's a relation, you can navigate the right thing.
for example, me, and my father. so, i can access father like this me.father also you can write a method me.getFather()
you design this pattern, need think the strength of relation.
if the instance is only one anywhere ,just like sun. you would think create a global, just like Ext

it's for a joke

4 May 2011, 4:02 AM
Thanks a lot guys. Looks like I've understood how to navigate elements using relations.
Just to clarify I got it right: from my button I have to do something like

Also I've got another question: is it possible to navigate elements using namespaces?
For example I have namespace App.nm1 which has grids,buttons,etc.
Is it possible to access elements something like