【问题标题】:EXT JS form panel with several partsEXT JS 表单面板有几个部分
【发布时间】:2011-09-02 08:28:22
【问题描述】:

如何创建具有较小部分的表单面板。较小的部分应该可以在表单面板中重复使用。

【问题讨论】:

    标签: forms extjs panel


    【解决方案1】:

    我正在为此使用助手。这是一个应该向您展示技巧的示例。

    /// limitForm : array with all ellemts that should be taken from the inner form. can be null or empty to take all
    FormContent.loginForm = function (limitForm) {
        var defaults = [
        {/* this has the ID 0 */
            xtype: 'Fieldset',
            title: 'Username',
            layout: 'form',
            items: [
                {
                    xtype: 'panel',
                    layout: 'form',
                    header: false,
                    hideBorders: true,
                    bodyBorder: false,
                    border: false,
                    height: 40,
                    items: [
                        {
                            xtype: 'textfield',
                            fieldLabel: 'Username',
                            regex: /^[\w\s\.]*$/,
                            regexText: 'No special chars allowed in this field',
                            anchor: '100%',
                            name: 'LoginName'
                        }
                    ]
                }
            ]
        }
        ,
        {/* this has the ID 1 */
            xtype: 'Fieldset',
            title: 'Additional data',
            layout: 'form',
            items: [
            {   
                xtype: 'panel',
                layout: 'column',
                header: false,
                border: false,
                bodyBorder: false,
                height: 40,
                items: [
                    {
                        xtype: 'panel',
                        layout: 'form',
                        header: false,
                        columnWidth: 0.5,
                        hideBorders: true,
                        bodyBorder: false,
                        border: false,
                        items: [
                            {
                                xtype: 'textfield',
                                fieldLabel: 'Title',
                                anchor: '100%',                                             
                                name: 'Title'
                            }
                        ]
                    },
                    {
                        xtype: 'panel',
                        layout: 'form',
                        header: false,
                        columnWidth: 0.5,
                        style: 'margin-left: 18px',
                        hideBorders: false,
                        border: false,
                        bodyBorder: false,
                        labelWidth: 65,
                        items: [
                            {
                                xtype: 'textfield',
                                fieldLabel: 'Title',
                                anchor: '100%',                                             
                                name: 'Title'
                            }
                        ]
                    }
                ]
            }
        }
        ];
    
        if (limitForm) {
            var ds = [];
            for (var i = 0, len = limitForm.length; i < len; i++) {
                ds.push(defaults[limitForm[i]]);
            }
            defaults = ds;
        }
    
        return defaults;
    }
    

    如果您想重用它,您可以使用配置数组或字段名修改函数参数(名称必须更改,否则只会提交一个字段)。但我认为它应该向您展示诀窍。

    确定这必须加载到主窗体中!

    【讨论】:

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