PDA

View Full Version : Ref not working for components in composite field



forumuser1080
2 May 2011, 9:45 AM
I thought I should be able to use the 'ref' attribute for components within a composite field.

IE I think this should work any one have any ideas:



var f = new Ext.form.FormPanel({
renderTo:'test'
,width:400
,height:300
,title:'testing'
,items:[{
xtype:'compositefield'
,fieldLabel:'Composite'
,items:[{
xtype:'textfield'
,name:'text'
,ref:'../textField'
},{
xtype:'button'
,text:'Test'
,ref:'../btnTest'
}]
}]
});
console.log(f.textField, f.btnTest);


I have tried adding more '../' with no luck. Try the example for yourself. Should this work??????

friend
2 May 2011, 10:02 AM
It seems broken for me as well...

forumuser1080
2 Jul 2011, 9:07 AM
Anyone have any ideas?

Again I am running 3.2.1.

skirtle
2 Jul 2011, 11:14 AM
It doesn't work in 3.2.1 but it does work in 3.3.1 and 3.4.0.

Seems to be this bit of code that does it:

http://dev.sencha.com/deploy/ext-3.4.0/docs/source/CompositeField.html#cfg-Ext.form.CompositeField-defaults

ref works by following the ownerCt chain. A composite field isn't a container so it doesn't add ownerCt to its items and as a result ref won't work automatically. In 3.4.0 this is worked around by wrapping the items in an extra container within the composite field and faking the ownerCt on the container to point to the composite field. All the refs have an extra '../' added to them to make this work the way you'd expect.