Results 1 to 2 of 2

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

  1. #1

    Question Ext.ux.form.CheckboxCombo checkbox with value="0" is always checked. Can't uncheck it

    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.

  2. #2
    Sencha User michael.pedrotti's Avatar
    Join Date
    Mar 2009
    Location
    Canoas, Rio Grande do Sul, Brasil
    Posts
    2

    Default Fix

    All checks do not consider the event check if the value is a string. I created a fix. Add before Ext.onReady.
    Code:
    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'.

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

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •