【问题标题】:Extjs radiogroup fieldLabel not displaying inside panelExtjs radiogroup fieldLabel 不显示在面板内
【发布时间】:2014-01-13 06:12:14
【问题描述】:

我正在使用ExtJs 2.3.0.

我有一个panel,里面有一个radiogroup,如下所示

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' }
                        ]
         }

问题是-
radioBox 的 fieldLabel '请选择' 未显示。我可以看到“是”/“否”单选按钮。

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

请告诉我为什么 fieldLabel 没有在面板内显示以及任何解决方法。

【问题讨论】:

    标签: extjs radiobuttonlist


    【解决方案1】:

    一方面,单个单选按钮必须是单选组的项目。在这里,您的配置对象中有重复的 items 键,这意味着您实际上最终在面板中有 2 个无线电,但没有无线电组。

    然后,简单面板不支持显示标签。为此,您必须使用 form panel

    最后,您可能希望为组中的所有收音机提供相同的name,以便myForm.getForm().getValues() 返回类似{myField: "Yes"} 的内容(该值将取自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'
            }]
        }]
    });
    

    【讨论】:

    猜你喜欢
    • 2011-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多