开发者

How to set layout to "fit" on an existing Ext.Panel? (.setLayout doesn't work)

开发者 https://www.devze.com 2023-01-28 13:13 出处:网络
I define my regionContent here: regionContent = new Ext.Panel({ region: \'center\', // layout: \'fit\', //used to be static, needs to be set dynamically now

I define my regionContent here:

regionContent = new Ext.Panel({
    region: 'center',
    // layout: 'fit', //used to be static, needs to be set dynamically now
    margins: '-1 0 0 -6',
    开发者_开发知识库autoScroll: true
});

Then later in a page that is loaded via AJAX, I empty the content of regionContent and add new content to it. At this time, how do I also change its layout to "fit"?

When I try to use .setLayout('fit'), I get the error layout.setContainer is not a function:

<script type="text/javascript">
    var start_info_panel = new Ext.Panel({
        padding: 10,
        width: 300,
        html: '<h1>Simple Text Page</h1><p>This is an example of a page with simple text.<p>'
    });
    replaceComponentContent2(regionContent, start_info_panel);

    function replaceComponentContent2(cmpParent, cmpContent) {
        clearExtjsComponent(cmpParent);
        cmpParent.add(cmpContent);
        cmpParent.setLayout('fit'); //error: "layout.setContainer is not a function"
        cmpParent.doLayout();
    }

    hideComponent(regionHelp);
</script>


It appears you are using the BorderLayout within the Parent Panel, and this error may be related to the following comment within the .add() function of any Container Type:

Warning: Containers directly managed by the BorderLayout layout manager may not be removed or added. See the Notes for BorderLayout for more details.

More info

Ext.Container .add() docs

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消