Skip to content Skip to sidebar Skip to footer

How To Set Radiogroup Radiofield Based On The Json Data Extjs 4

hi forum member I am having one problem with setting the radiofield in the extjs 4 my form radiogroup xtype code is given below { xtype: 'radiogroup', dataIndex: 'gender', ma

Solution 1:

First you should set inputValue to 'false' and 'true'. The second is the new design of a radiogroup. You will find the solution in my thread at the sencha forum See: http://www.sencha.com/forum/showthread.php?187185-Set-a-int-value-on-a-radiogroup-fails&goto=newpost

The problem is that setValue is expecting a object which would only be the case if you had to datatypes for gender; one for male and one for female... And that's the point why I posted this as bug. Down the override code from my post.

setValue: function (value) {
    if (!Ext.isObject(value)) {
        var obj = newObject();
        obj[this.name] = value;
        value = obj;
    }
    Ext.form.RadioGroup.prototype.setValue.call(this, value);
}  

Solution 2:

Actually, the problem is that you are trying to pass a boolean value to your radioBox:

"gender":false

which you are not supposed to.

The radioBox will be set to checked/unchecked if a true/false value is passed to its setValue method, ignoring what is the inputValue field set to.

Here is the source code, we can see that any other value passed in will finally end with a recursive call with boolean parameter:

setValue: function(v) {
    var me = this,
        active;

    if (Ext.isBoolean(v)) {
        me.callParent(arguments);
    } else {
        active = me.getManager().getWithValue(me.name, v, me.getFormId()).getAt(0);
        if (active) {
            active.setValue(true);
        }
    }
    return me;
}

Post a Comment for "How To Set Radiogroup Radiofield Based On The Json Data Extjs 4"