Condor
12-20-2008, 10:25 AM
Currently the ref config option can only be used to assign the component instance to a property of a single parent.
I would like to make a suggestion for the initRef method in the Ext trunk that would allow not only assignment to multiple parents, but also the possibility to create a back-reference to the parent in the component itself:
Ext.override(Ext.Component, {
initRef : function(){
if(this.ref){
var levels = this.ref.split('/'), i = levels.length - 1, t = this, n = levels[i];
while((--i >= 0) && (t = t.ownerCt)){
if(levels[i] && levels[i] != '.'){
this[levels[i]] = t;
}
if(n && ((i == 0) || levels[i])){
t[n] = this;
}
}
}
}
});
Example:
var v = new Ext.Viewport({
layout: 'fit',
items: [{
xtype: 'form',
title: 'Form',
items: [{
xtype: 'fieldset',
title: 'Fieldset',
defaultType: 'textfield',
items: [{
fieldLabel: 'Text',
name: 'text',
ref: 'viewport/.//textfield'
}]
}]
}]
});
After render, the viewport and the form will both contain a property 'textfield' and the text field will contain a property 'viewport'.
I would like to make a suggestion for the initRef method in the Ext trunk that would allow not only assignment to multiple parents, but also the possibility to create a back-reference to the parent in the component itself:
Ext.override(Ext.Component, {
initRef : function(){
if(this.ref){
var levels = this.ref.split('/'), i = levels.length - 1, t = this, n = levels[i];
while((--i >= 0) && (t = t.ownerCt)){
if(levels[i] && levels[i] != '.'){
this[levels[i]] = t;
}
if(n && ((i == 0) || levels[i])){
t[n] = this;
}
}
}
}
});
Example:
var v = new Ext.Viewport({
layout: 'fit',
items: [{
xtype: 'form',
title: 'Form',
items: [{
xtype: 'fieldset',
title: 'Fieldset',
defaultType: 'textfield',
items: [{
fieldLabel: 'Text',
name: 'text',
ref: 'viewport/.//textfield'
}]
}]
}]
});
After render, the viewport and the form will both contain a property 'textfield' and the text field will contain a property 'viewport'.