PDA

View Full Version : updating checkbox's checked value



scusyxx_xx
11 Mar 2010, 1:55 PM
Hi,
I have a panel with checkbox as menu item. What i want to do is to make checkbox 'checked' or 'unhecked' according to a javascript variable's value. The sample code is below.



panel = new Ext.Panel({
id: 'pppanel',
layout: 'border',
maxSize: 1200,
height: 600,
renderTo: somewhere,
items: [
{
region: 'center',
id: 'panel_center',
tbar: [{
xtype:'checkbox',
boxLabel: 'lalalaa ',
style: 'padding: 6px',
id: 'checkbox_id'

}]
}]
});

Ext.getCmp("checkbox_id").checked = true; // which doesnt work...

fay
12 Mar 2010, 2:24 AM
If you read the docs (http://www.extjs.com/deploy/dev/docs/?class=Ext.form.Checkbox) you'll see that "checked" is a config option, so modifying it after the checkbox is created has no effect. Read further down and you'll find setValue().

scusyxx_xx
12 Mar 2010, 6:23 AM
setValue() does not work.

fay
12 Mar 2010, 6:39 AM
does not work.

It most certainly does. I just tried it there now and it works... so you're obviously doing something else wrong...


Ext.getCmp("checkbox_id").setValue(true);