简体   繁体   English

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

[英]Ext js FormPanel is not showing panel items when toolbar is present

I seem to be having a weird issue here. 我似乎在这里有一个奇怪的问题。 An extended component has the following code: 扩展组件具有以下代码:

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
        });
    }
});

The issue is that when this panel renders, the toolbar is the only thing that renders. 问题在于,渲染此面板时,工具栏是唯一渲染的东西。 Through debugging I can see that BuildDetailItemArray() is being called correctly and returning the correct result. 通过调试,我可以看到正确调用了BuildDetailItemArray()并返回了正确的结果。

It gets even weirder when I comment out the this.tbar = line, because when the toolbar is not present, the fieldset and field renders correctly. 当我注释掉this.tbar =行时,它甚至变得更奇怪,因为当工具栏不存在时,字段集和字段将正确呈现。 This occurs even if I extend Panel instead of FormPanel . 即使我扩展Panel而不是FormPanelFormPanel发生这种情况。 I also tried abstracting out the form fields into it's own component, and the same thing occurs. 我还尝试将表单字段抽象到它自己的组件中,并且发生了同样的事情。

Anyone have any idea why this doesn't seem to work? 任何人都知道为什么这似乎行不通吗?

What sort of layout are you trying to put this panel into? 您正在尝试将哪种面板放入该布局? Also, are you setting a height for this panel? 另外,您是否要为此面板设置高度?

Often, if you aren't specifying a height for the component to be added (in your case, this panel), or you're not setting an anchor if using an AnchorLayout, component content won't be shown, but the toolbar still will. 通常,如果您没有指定要添加的组件的高度(在您的情况下,此面板),或者如果您未使用AnchorLayout设置锚点,则不会显示组件内容,但是工具栏仍然将。

It'd be good to know the context of this panel in your overall layout. 最好在整体布局中了解此面板的上下文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM