简体   繁体   中英

Extjs radiogroup setValue

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

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);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM