Extjs radiogroup setValue

599 views Asked by At

In my form radiogroup look like this

              {
                xtype: 'radiogroup',
                vertical: false,
                fieldLabel: ' ',
                labelSeparator: ' ',
                reference: 'radiofield',
                val: 1,
                items: [
                    {
                        boxLabel: 'Complete',
                        name: 'complete[20]',
                        inputValue: '1'
                    },
                    {
                        boxLabel: 'Incomplete',
                        name: 'complete[20]',
                        inputValue: '2'
                    }

                ]
            }, {
                xtype: 'radiogroup',
                vertical: false,
                fieldLabel: ' ',
                labelSeparator: ' ',
                reference: 'radiofield',
                val: 2,
                items: [
                    {
                        boxLabel: 'Complete',
                        name: 'complete[19]',
                        inputValue: '1'
                    },
                    {
                        boxLabel: 'Incomplete',
                        name: 'complete[19]',
                        inputValue: '2'
                    }

                ]
            },

and on Load method i am setting the values like this

Ext.each(ids, function(id){
        var g = mainPanel.down('radiogroup[val='+id+']');
        var name = 'complete['+id+']';
        g.setValue({name: 2});//the value can be either 1 or 2
    });

How do i set the values of the radiogroup note that when i give them hard coded values like this

g.setValue({'complete[19]': 2});

it works, any solution

1

There are 1 answers

0
CD.. On

Try this:

Ext.each(ids, function(id){
    var g = mainPanel.down('radiogroup[val='+id+']');
    var name = 'complete['+id+']',
    var value = {};

    value[name] = 2;

    g.setValue(value);
});