PDA

View Full Version : Referencing child components in ExtJS 4



msmolyak
8 Mar 2011, 8:16 AM
ExtJS 3 introduced a 'ref' attribute allowing the code to refer to the child components (nested at any level) of a given component using simple dot notation.

I am trying migrate the ExtJS 3 code that uses this technique to ExtJS 4 and getting errors stating that the child component is not defined. I checked the API documentation and was not able to find any trace of 'ref' attribute.

What happened to it? What is the proper way of referencing child components in ExtJS 4?

Michael

Animal
8 Mar 2011, 9:35 AM
http://docs.sencha.com/new/ext-js/4-0/api/Ext.ComponentQuery

http://docs.sencha.com/new/ext-js/4-0/api/Ext.container.Container#method-query

http://docs.sencha.com/new/ext-js/4-0/api/Ext.container.Container#method-child

http://docs.sencha.com/new/ext-js/4-0/api/Ext.container.Container#method-down

jack.slocum
26 Feb 2013, 4:33 PM
ref was removed in Ext 4? Why?

26 Feb 2013, 7:56 PM
Ref has limitations that proper component query usage overcomes.

jack.slocum
26 Feb 2013, 9:59 PM
??

The ref functionality should have been kept. However, it should have been modified to use component selectors/query instead of it's own syntax.

I put ref in the framework for a purpose, to automate the process of looking up child components, instead of manually querying. "proper component query usage" doesn't address or apply to that at all. Why would anyone want to write a whole line of query code to get a reference that could have been automatic. In a real app, ref can save you 100s of lines of code. I used it religiously in every app I wrote with Ext 3.

ethraza
16 Oct 2013, 11:19 AM
The greatest pain migrating ExtJs3 to 4 is been this, for me.

First time I saw this ref stuff in ExtJs3, it looked so amazing to simplify the access of deep nested items that I heavly used it.

There is some way, some plugin, some class, don't know, that bring ExtJs3 ref back?
Somebody have "up ported" it to Extjs4?

Thanks

------------
Now I saw that is Mr. Slocum just before me talking! Now I see why ExtJs 4 is been so odd.

BuckBazooka
4 Nov 2013, 5:10 AM
Great. None of the links that Animal is suggesting are working. :-(

burnnat
8 Nov 2013, 11:23 AM
Great. None of the links that Animal is suggesting are working. :-(

Their locations changed slightly. Try these:

http://docs.sencha.com/extjs/4.0.0/#!/api/Ext.ComponentQuery

http://docs.sencha.com/extjs/4.0.0/#!/api/Ext.container.Container-method-query

http://docs.sencha.com/extjs/4.0.0/#!/api/Ext.container.Container-method-child

http://docs.sencha.com/extjs/4.0.0/#!/api/Ext.container.Container-method-down

mangeshppatil
5 Aug 2014, 5:31 AM
if component id not singleton how can we get reference for it ....i am not able to assigne id so cant use this option for comboxes i am using