如何用新内容替换面板的内容? [英] How can I replace the content of a panel with new content?

查看:33
本文介绍了如何用新内容替换面板的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 regionContent 面板,可以添加到我的视口中.

I have a regionContent panel which I add to my viewport.

如何用新内容替换其内容?

    ...
    var regionContent = new Ext.Panel({
        id: 'contentArea',
        region: 'center',
        padding:'10',
        autoScroll: true,
        html: 'this is the original content'
    });

    var viewport = new Ext.Viewport({
        layout: 'border',
        items: [ regionMenu, regionContent ]
    });

    var newPanel = new Ext.Panel({
        region: 'east',
        title: 'Info Panel',
        width: 300,
        html: 'this is a panel that is added'
    });
    // regionContent.update(newPanel); //renders as javascript code ???
    // regionContent.remove(...) //how do I remove ALL CONTENT, I will not know what is in this panel to remove it specifically
    regionContent.add(newPanel); //adds to original content but does not replace it
    regionContent.doLayout();
    ...

.update() 这样做:

.add() 这样做:

推荐答案

您需要使用带有卡片布局的面板:

You'll want to use a panel with card layout:

var card=new Ext.Panel({
    layout:'card',
    activeItem:0,
    items:[ regionContent , newPanel ]
});

然后该面板可以进入您的视口.要在它们之间切换,您将使用以下内容:

That panel can then go inside your viewport. To switch between them you'll use something like this:

card.getLayout().setActiveItem(1);

看看两个卡片布局的工作示例:http://dev.extjs.com/deploy/dev/examples/layout-browser/layout-browser.html

Take a look at the two card layouts for working examples: http://dev.extjs.com/deploy/dev/examples/layout-browser/layout-browser.html

这篇关于如何用新内容替换面板的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆