javascript - 当工具栏存在时,Ext js FormPanel 不显示面板项目

标签 javascript extjs formpanel

我似乎遇到了一个奇怪的问题。扩展组件具有以下代码:

MyApp.panels.RelationshipDetails = Ext.extend(Ext.FormPanel, {
    closable: true,
    relationshipId: null,
    documentId: null,
    title: 'Relationship',
    initComponent: function () {
        if (!this.verifyRequiredData()) {
            MyApp.panels.RelationshipDetails.superclass.initComponent.call(this);
            return;
        }

        // Build components
        this.tbar = this.buildToolbar();
        this.items = this.buildDetailItemArray();

        MyApp.panels.RelationshipDetails.superclass.initComponent.call(this);
    },

    verifyRequiredData: function () {
        // Verification code here
    },

    buildDetailItemArray: function () {
        return [{
            xtype: 'fieldset',
            title: 'Details',
            collapsible: true,
            autoHeight: true,
            items: [{
                xtype: 'hidden',
                name: 'Id'
            }, {
                xtype: 'textfield',
                fieldLabel: 'Name',
                name: 'Name'
            }, {
                xtype: 'textfield',
                fieldLabel: 'Description',
                name: 'Description'
            }, {
                xtype: 'button',
                text: 'Save',
                name: 'saveButton'
            }]
        }];
    },

    buildToolbar: function () {
        return new Ext.Toolbar({
            // Toolbar Config
        });
    }
});

问题是,当此面板呈现时,工具栏是唯一呈现的东西。通过调试,我可以看到 BuildDetailItemArray() 被正确调用并返回正确的结果。

当我注释掉 this.tbar = 行时,情况变得更加奇怪,因为当工具栏不存在时,字段集和字段会正确呈现。即使我扩展 Panel 而不是 FormPanel,也会发生这种情况。我还尝试将表单字段抽象到它自己的组件中,并且发生了同样的事情。

有人知道为什么这似乎不起作用吗?

最佳答案

您想将此面板放入哪种布局?另外,您是否设置了该面板的高度?

通常,如果您没有指定要添加的组件的高度(在您的例子中是此面板),或者如果使用 AnchorLayout,则没有设置 anchor ,则不会显示组件内容,但是工具栏仍然会。

最好了解该面板在整体布局中的上下文。

关于javascript - 当工具栏存在时,Ext js FormPanel 不显示面板项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4461229/

相关文章:

extjs - ExtJs通过以字符串开头的id选择组件

javascript - ExtJS 使用数据库中的数据 (JSON) 填充 Ext.FormPanel

javascript - 使用循环添加标签字段(ExtJs 2.3.0)

javascript - 更改选择javascript的值

javascript - 从给定的对象中获取数组对象字符串

javascript - 使用 Ken Wheeler 的 slick slider 实现中心 slider 时遇到问题

javascript - ExtJs 布局 : Can't display Ext. form.Panel

javascript - ExtJS:如何在添加按钮之前获取按钮的宽度?

javascript - ExtJs 工具栏配置对象

javascript - Sencha Touch 日期代码在 Chrome 中运行良好,但在 Safari 中失败