ExtJs 添加面板作为选项卡项
我有一个 设置,其中预计将根据用户选择加载选项卡左面板树中的项目。我的目标是根据用户选择仅将相关项目加载到特定选项卡。
第一次,我能够添加项目如下:
var tab = tabs1.getItem('Orders');
tab.remove(0);
tab.add(pane33);
tab.doLayout();
但是,当用户再次选择该项目时,面板项目已被删除,并且错误为 (c.getPositionEl().dom is undefined)。
该错误是由于该项目被删除或销毁造成的。似乎没有选项可以替换选项卡项目或刷新/重新加载面板。
这要怎么处理呢?
谢谢。
I have a setup where the tab is expected to be loaded based on user selection of an item from a left panel tree. My objective is to load only the relevant items as per the user selection to a particular tab.
The first time, I am able to add item as below:
var tab = tabs1.getItem('Orders');
tab.remove(0);
tab.add(pane33);
tab.doLayout();
But, when the user selects the item again, the panel item is already removed, and errors out as (c.getPositionEl().dom is undefined
).
The error is due to the item being removed or destroyed. There seems no option to replace the tab item, or to refresh/reload panels.
How to handle this?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Container.remove
有一个可选的第二个参数autoDestroy
,这意味着被删除的组件也会被永久销毁(对于 TabPanel,默认为 true) 。您仅实例化您的子组件一次,因此在它们被销毁后,将无法再添加它们。要么传递autoDestroy: false
(这也可以在 TabPanel 级别设置)并在删除现有组件后隐藏它们(然后只需在后续单击时显示它们),否则您必须在之前重新实例化它们每次都添加。Container.remove
has an optional second argumentautoDestroy
, which means the component being removed is also destroyed permanently (for TabPanels, this defaults to true). You are only instantiating your child components one time, so after they get destroyed they are no longer available to be added. Either passautoDestroy: false
(this can be set at the TabPanel level as well) and hide existing components after removing them (then simply show them on subsequent clicks), or you'll have to reinstantiate them before adding each time.您可以将该选择标记为“已选择”并检查鼠标操作。作为一种简单的方法。
you can mark that selection as 'selected' and check at mouse actions. as a simple approach.