extJS RadioGroup setValue()函数

Sap*_*pan 8 extjs radio-group setvalue

我使用代码创建了RadioGroup

var radios = new Ext.form.RadioGroup({
     columns    : 2,
       items: [
             {boxLabel: 'E-Mail', name: 'communication', inputValue: 1},
             {boxLabel: 'Nagios', name: 'communication', inputValue: 2}
        ]
   });
Run Code Online (Sandbox Code Playgroud)

我想检查某个事件上的一个单选按钮.怎么做?我试过用:

radios.setValue(true, false);
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

mus*_*.0x 13

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.RadioGroup-method-setValue

var form = Ext.create('Ext.form.Panel', {
    title       : 'RadioGroup Example',
    width       : 300,
    bodyPadding : 10,
    renderTo    : Ext.getBody(),
    items       : [
        {
            xtype      : 'radiogroup',
            fieldLabel : 'Group',
            items      : [
                { boxLabel : 'Item 1', name : 'rb', inputValue : 1 },
                { boxLabel : 'Item 2', name : 'rb', inputValue : 2 }
            ]
        }
    ],
    tbar        : [
        {
            text    : 'setValue on RadioGroup',
            handler : function () {
                // Set the value of the 'rb' radio butons
                var val = {rb : 2};
                form.child('radiogroup').setValue(val);
            }
        }
    ]
});
Run Code Online (Sandbox Code Playgroud)


Pul*_*yal 11

radios.items.items应该返回收音机组内的单选按钮.然后,您可以对它们使用setValue()函数来检查或取消选中它们.

radios.items.items[index].setValue(true/false);
Run Code Online (Sandbox Code Playgroud)

  • 但是我们如何使用RadioGroup的setValue()?这适用于个人,但整体组 (4认同)

小智 6

例如,选择"电子邮件"

radios.setValue({communication: 1});
Run Code Online (Sandbox Code Playgroud)

一般使用:

radioGroup_var.setValue({radioGroup_name: 'inputValue'});
Run Code Online (Sandbox Code Playgroud)