Extjs radiogroup fieldLabel不显示在面板内 [英] Extjs radiogroup fieldLabel not displaying inside panel

查看:431
本文介绍了Extjs radiogroup fieldLabel不显示在面板内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 ExtJs 2.3.0。

我有一个面板,里面有一个 radiogroup 如下

I have a panel and inside it a radiogroup as follows

var testPanel = {
          xtype: 'panel',  
          border: false,
          items: [ 
                    { fieldLabel: 'Please select ', 
                      xtype: 'radiogroup', 
                      id: 'id1', 
                      columns: 2, 
                      vertical: false
                    }
                 ],
                 items: [
                            { boxLabel: 'Yes', name: 'yes', inputValue: 'Yes', xtype: 'radio'},
                            { boxLabel: 'No', name: 'no', inputValue: 'No', xtype: 'radio' }
                        ]
         }

问题是 - / strong>

fieldLabel'请选择'的radioBox是不显示。我可以看到是/否单选按钮。

The issue is-
The fieldLabel 'Please select' of radioBox is not displaying. I am able to see 'Yes'/ 'No' radiobuttons.

当我将testPanel的xtype更改为form时,会显示标签。
但是,我不能使用'form'xtype。我只想使用面板。

When I change xtype of testPanel to 'form', the label displays. However, I can't use 'form' xtype. I want to use 'Panel' only.

请让我知道fieldLabel为什么不在面板内部和其他任何解决方法。

Please let me know why the fieldLabel is not diaplying inside panel and any workaround for this.

推荐答案

一方面,个人单选按钮必须是广播组的项目。在这里,您已经在配置对象中复制了项目项,这意味着您的面板中最终会出现2个无线电,但没有收音机组。

For one thing, the individual radio buttons must be items of the radio group. Here, you've got the items keys that is duplicated in your config object, meaning you actually end up with 2 radios in your panel, but no radio group.

然后,简单的面板不支持显示标签。您必须使用表单面板

Then, simple panels do not have support for displaying labels. You must use a form panel for that.

最后,您可能想要给组中所有的收音机一样的名称,以便 myForm.getForm ().getValues()返回类似 {myField:Yes} (该值将从 inputValue

Finally, you probably want to give all the radio in the group the same name, so that myForm.getForm().getValues() returns something like {myField: "Yes"} (the value will be taken from inputValue).

所以这里是你要做的:

Ext.ComponentMgr.create({
    xtype: 'form', // notice the changed xtype
    renderTo: Ext.getBody(),
    border: false,
    items: [{
        fieldLabel: 'Please select ',
        xtype: 'radiogroup',
        id: 'id1',
        columns: 2,
        vertical: false,
        // radio buttons must be children of the radio group
        items: [{
            boxLabel: 'Yes',
            // you probably want to give your radios the same name
            name: 'myField',
            inputValue: 'Yes'
        }, {
            boxLabel: 'No',
            name: 'myField',
            inputValue: 'No'
        }]
    }]
});

这篇关于Extjs radiogroup fieldLabel不显示在面板内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆