I am looking for a way to access components / field that are either in the same items array as the accessing one or even only in a same parent items array (the last one is just a option).
In ExtJS3 this was easy by simply defining a ref
in the owner container but I didn't found anything like that in ExtJS4.
I know that I can use Ext.ComponentQuery()
or the shortcuts up()
/ down()
or even Ext.getCmp()
but they are all not what I am looking for, cause they just executes a bunch of code while the ref
was such an easy Way to do things.
Yes, I am aware of the fact that using a ComponentQuery is much more fail safe than the use of hard coded references. But I just want to know if there are some other ways to do this.
Alternately, for your case of getting the next element in a container, you can use the nextSibling
or prevSibling
. All components have these methods. It would be a little less walking around the DOM structure. They also allow for a selector argument.
They are described in the docs here.
Here are some tricks I have used:
//lookup by name
formPanel.getForm().findField('state');
//lookup using nextSibling/prevSibling in a fieldset or fieldcontainer
myField.ownerCt.nextSibling('textfield[fieldLabel=Description]')
Here fieldLabel
property is used to narrow down field selection but you can use ANY property at all. So if you construct a field with a property ref
you can then use it to select your field similar how you would use it in a ComponentQuery
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With