dynamic add items to border viewport

橙三吉。 提交于 2019-12-10 10:05:23

问题


I want to create a empty viewport(layout:border) first, then add items to it, finally render and show. but when I created the viewport element, it throw an error, says:

Uncaught TypeError: Cannot read property 'flex' of undefined

here are my code:

<script type="text/javascript" src="ext-4.0.2a/bootstrap.js"></script>
<script>
Ext.require(['*']);
Ext.onReady(function() {
    Ext.QuickTips.init();

    var viewport = Ext.create('Ext.container.Viewport', {
        layout: 'border'
    });

    var north = blablabla...
    viewport.add([north,south]);

    viewport.doLayout();
});
</script>

回答1:


According to notes that are taken from docs:

The regions of a BorderLayout are fixed at render time and thereafter, its child Components may not be removed or added.To add/remove Components within a BorderLayout, have them wrapped by an additional Container which is directly managed by the BorderLayout.

And by the way

Any Container using the Border layout must have a child item with region:'center'



来源:https://stackoverflow.com/questions/6874016/dynamic-add-items-to-border-viewport

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!