PDA

View Full Version : How to update checkbox box label



JacobGu
29 Aug 2012, 12:52 PM
I'd like to update a checkbox box label, ideally using beforeBoxLabelTpl with a data object that can change. I don't quite see how to do this, other than destroying the component and re-creating it. Is that what I need to do?

Thanks.

JacobGu
29 Aug 2012, 1:02 PM
This is one way to do it, but I was just wondering if there is an update method that will accomplish what lines 2-4 of the code below do.


checkbox.subTplData = {yearCost: totalYearPrice, yearSavings: yearSavings};
checkbox.getEl().down('td[role=presentation]').setHTML(annual.getSubTplMarkup());
checkbox.inputEl = annual.getEl().down('input');
checkbox.initEvents();

sword-it
29 Aug 2012, 10:32 PM
Hi!
which Extjs 4 version are you using?

if you are using 4.1.0 or later, then you may use setFieldLabel()

check this:-
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.Checkbox-method-setFieldLabel

JacobGu
30 Aug 2012, 3:03 AM
Hi-

I am using 4.1 and tried your solution of setFieldLabel (and using fieldLabel with labelAlign:'right', instead of boxLabel), but it creates two checkboxes. There's probably some way to get it to work, but since the solution posted in my prior message works and is only 4 lines of code, I decided to stick with it and move on to bigger problems.

Thanks.