PDA

View Full Version : How to update boxLabel for a radio button after rendering?



bjnelson62
17 Jan 2013, 8:16 AM
I've looked in the debugger, and through all the code for the radio button, checkbox, and the Container classes.

I did find a couple of old (3.X) forum answers on this, but that code doesn't work:



Ext.define('VFABRIC.form.RadioField', {
extend: 'Ext.form.field.Radio',
alias: 'widget.vfabricradiofield',


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


constructor: function(config) {
this.callSuper(arguments); // calls superclass's constructor//...
},


});


Is there a way to do this in 4.X of ExtJS?

My workaround is to remove the radio button and re-add it, but that's pretty grody.

mitchellsimoens
21 Jan 2013, 11:11 AM
This worked for me:


Ext.define('MyRadio', {
extend : 'Ext.form.field.Radio',
xtype : 'myradio',

setBoxLabel : function(label) {
this.boxLabel = label;

this.rendered && this.boxLabelEl.update(label);
}
});

bjnelson62
23 Jan 2013, 6:20 AM
Awesome! Thanks so much.

I spent quite a bit of time trying different things, this saves me a lot of time. Hopefully it will help someone else too.