PDA

View Full Version : Need to change the boxLabel of Radio at runtime



punit
30 Dec 2009, 12:27 AM
Hi,

I need to change the boxLabel of a radio at runtime.
I did this overriding for this purpose, that is working fine. But I am new to ExtJS, so I want to know is there any better way than this to achieve this need.


Ext.override(Ext.form.Radio,
{
setBoxLabel: function(label)
{
var labelEl=this.el.next("label");
if (labelEl)
labelEl.update(label);
}
});

Condor
30 Dec 2009, 1:26 AM
Use:

Ext.override(Ext.form.Checkbox, {
setBoxLabel: function(boxLabel){
this.boxLabel = boxLabel;
if(this.rendered){
this.wrap.child('.x-form-cb-label').update(boxLabel);
}
}
});
(Ext.form.Radio descends from Ext.form.Checkbox)

sheela
30 Dec 2009, 1:43 AM
Thanks for the info

punit
30 Dec 2009, 1:54 AM
Thank you very much :), got the whole idea, get the wrapper parent element using this.wrap, and find label element using class attribute,

<div>
<input ...> //checkbox or its descendent
<label class="x-form-cb-label" ...> box label </label>
</div>
and then change the value of the label element.
Great thanks.

emkramer
16 Dec 2013, 3:10 PM
Where does this code go in the source?