PDA

View Full Version : Get first component added



Daniels
22 Sep 2009, 10:46 AM
How i get the first component added? I don't find a way to do this.

Daniels
23 Sep 2009, 4:14 AM
Is so hard to do this? Maybe it's no so simple when I thought.

Animal
23 Sep 2009, 4:40 AM
The first child item? It's easy if you read the docs first.

http://www.extjs.com/deploy/ext-3.0.0/docs/?class=Ext.Container&member=items

Daniels
23 Sep 2009, 4:44 AM
The first child item? It's easy if you read the docs first.

http://www.extjs.com/deploy/ext-3.0.0/docs/?class=Ext.Container&member=items

Well, I know this function, but don't solve my problem. I don't have a container on hands. I can't call Ext.getCmp(id), because i don't have the id of any component. I need a function like Ext.getCmp(0), where 0 is the first item added in Ext.onReady();

Animal
23 Sep 2009, 5:03 AM
OK, back to basics. What application problem are you trying to solve?

The first Component of any kind added to any Container is not really anything useful.

Daniels
23 Sep 2009, 5:30 AM
OK, back to basics. What application problem are you trying to solve?

The first Component of any kind added to any Container is not really anything useful.

I have some panels. This panels have items and items have items too and etc. It's a containers tree. I have a situation where I get one of this panels and I need add this panel in the root panel. Well, the one solution i have in mind is get the root panel, and add the component, simple like this. I just don't know how to get it.

Animal
23 Sep 2009, 6:07 AM
I don't understand at all.

If you are in control, then why this requirement for an arbitrary "first Component"?

Daniels
23 Sep 2009, 6:24 AM
I don't understand at all.

If you are in control, then why this requirement for an arbitrary "first Component"?

Well, let's go for an example. Look the picture bellow.

The Viewport has 4 components. ext-comp-1001 in west, C in north, D on center and the south has D. ext-comp-1001 has two components: A on center, B on east.

I want to move panel B to north, above C. It's no possible in BorderLayout, but I have a Layout which extends BorderLayout and enable this function. Well, today I get the Viewport by Ext.getCmp('viewport'). If my Viewport don't have a id called 'viewport' I have a big problem.

I need the Viewport component on my hands, but I just can get it by Id. I need this by other way.

mrsunshine
23 Sep 2009, 6:49 AM
you can use for example

ref (http://extjs.net/deploy/dev/docs/source/Component.html#cfg-Ext.Component-ref) or itemId
(http://extjs.net/deploy/dev/docs/source/Component.html#cfg-Ext.Component-itemId)

Animal
23 Sep 2009, 6:59 AM
It just so happens that "A" is the first one (You know that), "A" is the only one you want to move (You know that)?

But you still want some floppy "first component" thing? If you are in control, either use an id, or an itemId, or the ref config, or keep a reference to it as an instantiated Component.

Daniels
23 Sep 2009, 8:47 AM
It just so happens that "A" is the first one (You know that), "A" is the only one you want to move (You know that)?


I can move anyone, "A" is just an example. "A" isn't the first component.



But you still want some floppy "first component" thing? If you are in control, either use an id, or an itemId, or the ref config, or keep a reference to it as an instantiated Component.

I don't have a control of Viewport, which in this case is the "first component" that I want. The user set this layout, some plugins for what they want and it need works. I have no idea what is on the screen. The "A" I get when user drag the component. The Viewport I don't know what do for get.

The screen is just an example. You can make your own config, and it needs works.