extjs动态地向选项卡添加网格?

| 在我的extjs标签面板中,有一个标签。在标签中,我做了:
this.tab.add(this.someGrid1);
现在基于特定条件,我想做:
if (cond ==true)
this.tab.remove(this.someGrid1);
this.tab.add(this.someGrid2);
这可能吗? 我试过没有删除,它不起作用。什么都没发生,旧的someGrid1仍然存在。 编辑:通过建议,我将代码更改为:
if (cond ==true)
this.tab.remove(this.someGrid1);
this.tab.add(this.someGrid2);
this.tab.doLayout();

else if (cond ==false)
this.tab.remove(this.someGrid2);
this.tab.add(this.someGrid1);
this.tab.doLayout();
加载页面时,
cond == true
表示一切正常。当我通过组合将cond更改为false时,someGrid1加载正常。 当我改回
cond ==true
时,代码不会执行超出
this.tab.add(this.someGrid2);
this.tab.doLayout();
并且someGrid2不呈现。错误是这样的:
Error: b.getPositionEl().dom is undefined
    
已邀请:
在运行时动态添加和删除组件时,必须确保Ext触发组件的重新呈现,以确保更改后的状态得以反映。我实际上不知道您的面板的确切结构,但假设
this.tab
Ext.TabPanel
this.tab.doLayout();
重新渲染组件。     
该代码对我来说似乎正确。您是否尝试过调试并在调用
remove
方法时验证是否正确设置了
this.someGrid1
?在Ext中弄乱您的
this
示波器很容易。 没关系,但是您也可以尝试将
true
作为第二个参数添加到
remove
。这将迫使Ext破坏该组件,并且与其关联的所有dom都将消失。 如果您仍然无法正常工作,也许会发布一些其他代码,但是我敢打赌,如果您使用Firebug并调试此功能,解决方案将显而易见。     
dom在ѭ11上被破坏,因此您必须重新创建div。这就是为什么您会收到
dom is undefined
错误消息的原因。     

要回复问题请先登录注册