View Full Version : Duplicate IDs

9 Nov 2010, 10:23 PM
I for one really miss the custom Google search for the forums :(
Since I can't find anything after quite a while of searching, I thought I'd put the question out.

What is the best way to place refs to deeply nested form field at the forefront of a panel component?
I'm trying to avoid the complication and confusing '../../../../../../formField' situation.

Alternatively, I'm using itemId on my fields, and finding a need to use find('itemId', 'formField') to grab the nested component. It's a bit nasty if you have a lot of find() lines.

Should I be using id values on each of my components which are deeply nested, and then use findById()? If I have multiple instances of said nested panel, won't it cause confusion by having duplicate id values present? or is it only an issue if you use Ext.getCmp()?

The documentation and examples I've seen weren't very clear, or didn't suggest an alternative for deeply nested components.


10 Nov 2010, 2:52 AM
I've been through exactly the same scenario as you and have come to the conclusion that using an "id" (and Ext.getCmp("someID")) on deeply nested object structures is the way to go. ID collisions are obviously an issue, but a little intelligent, reverse polish notation style naming usually takes care of that.

I use "ref: ../objName" only if I need to move a child object reference up one level.


10 Nov 2010, 3:05 AM
Hardcoded IDs are not the best way.

Accessing deeply nested items is not that easy right now, but there is a better way arriving in Ext 4 which is already part of the infrastructure which underpins Sencha Touch.


All built upon http://dev.sencha.com/deploy/touch/docs/?class=Ext.ComponentQuery

This is like the familiar DOM querying and selection machinery we have all come to know and use.

You will be able to reach down (or, hopefully, if they accept my suggestions, up into parent Containers) to find exactly the Component(s) you want.

10 Nov 2010, 2:07 PM
Thanks very much to both of you for taking the time to help.

It really sucks if you have FormPanel > Panel > Panel with columns > Field in column since it ends up being so deeply nested.

One question - is the performance hit of Component > find() that high?

Ext4 sounds great!