1. #1
    Sencha User martin17's Avatar
    Join Date
    May 2008
    Location
    Argentina
    Posts
    10
    Vote Rating
    0
    martin17 is on a distinguished road

      0  

    Default [B3] Ext.form.RadioGroup setValue method bug

    [B3] Ext.form.RadioGroup setValue method bug


    Ext.form.RadioGroup setValue method don't work in beta 3:
    From ext-all-dev (line 124927)
    Code:
     setValue: function(value) {
            var cbValue, first, formId, radios,
                r, rLen, name;
    
    
            if (Ext.isObject(value)) {
                for (name in value) {
                    if (value.hasOwnProperty(name)) {
                        cbValue = value[name];
                        first  = this.items.first();
                        formId = first ? first.getFormId() : null;
                        radios = Ext.form.RadioManager.getWithValue(name, cbValue, formId);
                        rLen   = radios.length;
    
    
                        for (r = 0; r < rLen; r++) {
                            radios[r].setValue(true);
                        }
                    }
                }
            }
            return me;
        }
    Corrected:
    Code:
    setValue: function(value) {
     var me = this; 
            var cbValue, first, formId, radios,
                r, rLen, name;
    
    
            if (Ext.isObject(value)) {
                for (name in value) {
                    if (value.hasOwnProperty(name)) {
                        cbValue = value[name];
                        first  = this.items.first();
                        formId = first ? first.getFormId() : null;
                        radios = Ext.form.RadioManager.getWithValue(name, cbValue, formId);
                        rLen   = radios.length;
    
    
                        for (r = 0; r < rLen; r++) {
                            radios.items[r].setValue(true);
                        }
                    }
                }
            }
            return me;
        }

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,004
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    The source to this method has changed since b3 and should be fixed. Here is an override you can try:

    Code:
    Ext.define('Override.form.RadioGroup', {
        override : 'Ext.form.RadioGroup',
    
        setValue: function(value) {
            var cbValue, first, formId, radios,
                i, len, name;
    
            if (Ext.isObject(value)) {
                for (name in value) {
                    if (value.hasOwnProperty(name)) {
                        cbValue = value[name];
                        first = this.items.first();
                        formId = first ? first.getFormId() : null;
                        radios = Ext.form.RadioManager.getWithValue(name, cbValue, formId).items;
                        len = radios.length;
    
                        for (i = 0; i < len; ++i) {
                            radios[i].setValue(true);
                        }
                    }
                }
            }
            return this;
        }
    });
    Pretty much the same as what you did except a little more performant (very very insignificant though) where we added the items key.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1