PDA

View Full Version : Ext.ux.form.CheckboxCombo checkbox with value="0" is always checked. Can't uncheck it



dreamliner
9 Aug 2011, 5:37 AM
Hey guys! I have a following question:

I'm using Ext.ux.form.CheckboxCombo to make a multiple-selections checkboxes list. But the problem is when i use value="0" here:

addCheckboxes (Ext.ux.form.CheckboxCombo.js):

...
Ext.each(this.store.data.items, function(rec) {
var checkbox = new Ext.form.Checkbox({name: rec.data.id + '-checkbox', boxLabel: rec.data[this.displayField], inputValue: rec.data[this.valueField], checked: (rec.checked ? rec.checked : false)});
this.cbgroup.items.add(checkbox);
col.add(checkbox);
}, this);
...

The very first checkbox inputValue is "0". Is it a bug or something but when it is outputed in a form that first checkbox is always selected and i can't uncheck it! Why is it happening and how to fix it. Thanks.

michael.pedrotti
23 Dec 2011, 4:21 AM
All checks do not consider the event check if the value is a string. I created a fix. Add before Ext.onReady.


Ext.override
(
Ext.form.Checkbox,
{
setValue:function(v){

var checked = this.checked, inputVal = this.inputValue;

if(v === false)
{
this.checked = false;
}
else
{
this.checked = (v === true || v === 'true' || v == '1' || (v instanceof String) || (inputVal ? v == inputVal : String(v).toLowerCase() == 'on'));
}

if(this.rendered)
{
this.el.dom.checked = this.checked;
this.el.dom.defaultChecked = this.checked;
}
if(checked != this.checked)
{
this.fireEvent('check', this, this.checked);
if(this.handler)
{
this.handler.call(this.scope || this, this, this.checked);
}
}
return this;
}
}
);

inputValue must be a String '0'.



{
xtype:'checkbox',
fieldLabel:'Caption',
labelSeparator:':',
boxLabel:'LabelText',
name:'status',
inputValue:'0'
}