PDA

View Full Version : Accessing nested items in a form



spbroom
11 May 2009, 3:36 AM
Hi, a quick question:

I have a formPanel that's fairly complex in terms of layout, lots of nested columns tabs etc.

I am using a factory to return different instances of the form to use in different situations and I want occasionaly to change the title of a tab.

On simpler forms if I wanted to accessthe items within the form I just used the formPanel.items property and worked from there. Is there an easy way to reference an item that is more deeply nested?

Thanks for the help.

Stuart

Condor
11 May 2009, 3:38 AM
For FormPanels you can use:

var field = formPanel.getForm().findField('idOrNameOfField');
(but this only works if the field is already rendered)

spbroom
11 May 2009, 4:29 AM
Thanks, that works great for actual fields in the form. But what about something like a tab title, can I do something similar for that?

Cheers for the help

Condor
11 May 2009, 4:40 AM
For other components you either:
1. Use itemIds, e.g.

var fieldset = container.getComponent('itemIdOfTabPanel')
.getComponent('itemIdOfPanel')
.getComponent('itemIdOfFieldset');
(drawback: you have to know the container structure at runtime)
2. Use ids, e.g.

var fieldset = Ext.getCmp('idOfFieldset');
(drawback: ids need to be unique throughout the page)
3. Use ref (Ext 3 only), e.g.

{xtype: 'fieldset', ref: '///myfieldset'}
...
var fieldset = container.myfieldset;
(drawback: you have to know the container structure at designtime)

spbroom
11 May 2009, 5:31 AM
That's what I need. Thanks