Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Ext JS中设置RadioGroup setValue()函数?_Javascript_Jquery_Extjs_Sencha Touch_Sencha Architect - Fatal编程技术网

Javascript 如何在Ext JS中设置RadioGroup setValue()函数?

Javascript 如何在Ext JS中设置RadioGroup setValue()函数?,javascript,jquery,extjs,sencha-touch,sencha-architect,Javascript,Jquery,Extjs,Sencha Touch,Sencha Architect,我有一个单选组,有男按钮和女按钮。 请参阅下面的代码 { xtype: 'radiogroup', fieldLabel: 'Gender', name: 'rbGender', defaults: { flex: 1 }, layout: 'hbox', items: [ { boxLabel: 'Male', name: 'gender',

我有一个单选组,有男按钮和女按钮。 请参阅下面的代码

{
    xtype: 'radiogroup',
    fieldLabel: 'Gender',
    name: 'rbGender',
    defaults: {
        flex: 1
    },
    layout: 'hbox',
    items: [
        {
            boxLabel: 'Male',
            name: 'gender',
            inputValue: false,
            //checked: true,
            id: 'radio1'
        },
        {
            boxLabel: 'Female',
            name: 'gender',
            inputValue: true,
            id: 'radio2'
        }
    ]
}
当我从性别字段男性或女性(真/假)的数据库中获取值时,我无法设置这些无线电字段

请参阅下面的代码

 if (rec[0].gender == true) {
     me.form.getForm().findField('gender').setValue(true);
 }
 else if (rec[0].gender == false) {
     me.form.getForm().findField('gender').setValue(true);
 };

如何通过数据库性别字段值设置男女单选按钮只需传递一个对象,以单选项名称作为键和值,如:

setValue({gender: true}) // will set the female as selected.
工作示例: