我有一个regionContent
面板,我添加到我的视口.
如何用新内容替换其内容?
...
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();
...
Run Code Online (Sandbox Code Playgroud)
.update()
做这个:
.add()
做这个:
您将需要使用具有卡片布局的面板:
var card=new Ext.Panel({
layout:'card',
activeItem:0,
items:[ regionContent , newPanel ]
});
Run Code Online (Sandbox Code Playgroud)
然后该面板可以进入您的视口.要在它们之间切换,您将使用以下内容:
card.getLayout().setActiveItem(1);
Run Code Online (Sandbox Code Playgroud)
看看两个卡片布局的工作示例:http: //dev.extjs.com/deploy/dev/examples/layout-browser/layout-browser.html
您无法删除HTML .remove()
,因为它不被视为面板的项目.所以你需要用来.update()
摆脱那个HTML,然后添加你的新面板.
// clear the html by replacing it with an empty string.
// calling update with no arguments would work as well.
regionContent.update('');
// add the new component
regionContent.add(newPanel);
// redraw the containing panel
regionContent.doLayout();
Run Code Online (Sandbox Code Playgroud)
从您的屏幕截图中看,您可能已经.update()
通过传入新面板使用,例如.update(newPanel)
.该方法用于更新HTML,而不是替换组件.走相反的道路:
regionContent.removeAll(); // if you want to remove all the items
regionContent.update('this is the original content');
regionContent.doLayout();
Run Code Online (Sandbox Code Playgroud)
您是否真的使用您发布的解决方案来解决这个问题?对我来说,clearExtjsComponent()
留下HTML字符串"这是原始内容",就像你的截图一样.
归档时间: |
|
查看次数: |
35664 次 |
最近记录: |