添加和删​​除内容到 tabPanel 时出错 - ExtJs

发布于 2024-11-07 02:16:46 字数 1580 浏览 8 评论 0原文

我有一个使用 ExtJS 框架构建的网络应用程序。

我的西面板有一棵树,中间面板有一个 TabPanel。当我单击西面板树上的任何节点时,它尝试将表单添加到中心 TabPanel 上,调用以下代码:

var center = Ext.getCmp("center-panel");

var existingpanel = center.get(panelId);
if (existingpanel) {
    center.setActiveTab(existingpanel);
} else {

    var activeTab = center.getActiveTab();

    if (!openNew && activeTab) {
        var removed = center.remove(activeTab, true);
    }

        center.add(c);
        center.setActiveTab(panelId);
        center.doLayout();

}

这将检索当前组件,然后检查我们是否正在尝试使用该选项卡加载是否存在,如果它确实存在,那么它只会激活该选项卡,否则它将尝试添加一个新选项卡。 OpenNew 只是一个传入的标志,用于指示是否应在新选项卡中打开它(例如,如果用户 ctrl+单击树上的节点)。

在不使用 OpenNew 功能(例如仅使用一个选项卡)的情况下,表单可以正常工作,并且我可以在正确删除/重新添加选项卡的情况下在节点之间导航。

但是,如果我 ctrl+单击一个节点来打开第二个选项卡,则该选项卡首先打开,因此有两个选项卡,但是当我选择另一个节点时(因此这应该删除最近添加的第二个选项卡并将其替换为新节点的新选项卡)它只是关闭第二个选项卡,但无法添加新选项卡。

我看不出其背后的任何原因,因为当只有单个选项卡时,它会添加/删除选项卡。

FireBug 中有一个错误,但它没有提供太多帮助:

uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOM3Node.compareDocumentPosition]"  nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame :: /ext/ext-3.1.1/adapter/ext/ext-base-debug.js?d=1066331810 :: <TOP_LEVEL> :: line 1900"  data: no]

----------更新:--------------

它似乎与 doLayout() 调用相关 - 如果我将 doLayout() 调用直接放在remove() 调用之后,那么它不会像 add() 调用那样庞大,并且如果我将它放在 .add() 之后调用然后它会一半加载新选项卡,但在完成之前停止。

如果我在两个选项卡之后都有一个 doLayout() 调用,那么它的工作效果会更好一些,然后我可以有两个功能选项卡,但是当我尝试添加第三个选项卡时,它会显示与上面相同的行为,并关闭第三个选项卡并关闭不重新开新的了..

I have a web app built using ExtJS framework.

I have a tree in my west panel, and in the center panel a TabPanel. When I click on any of the nodes on the tree in the west panel it attempts to add a form on to the center TabPanel, the following code is called:

var center = Ext.getCmp("center-panel");

var existingpanel = center.get(panelId);
if (existingpanel) {
    center.setActiveTab(existingpanel);
} else {

    var activeTab = center.getActiveTab();

    if (!openNew && activeTab) {
        var removed = center.remove(activeTab, true);
    }

        center.add(c);
        center.setActiveTab(panelId);
        center.doLayout();

}

This retrieves the current component, and then checks to see if the tab we are attempting to load exists, if it does exist then it just activates that tab, otherwise it will attempt to add a new one.
The OpenNew s just a flag that is passed in to state whether it should be opened in a new tab (for example if the user ctrl+clicks the node on tree).

Without using the OpenNew functionality (e.g. with just one tab) the form works correctly, and I can navigate between nodes with the tabs being removed/re-added correctly.

However, if I ctrl+click a node to open a second tab, the tab opens at first, so there are two tabs, but then when I select another node (so this should just remove the recently added second tab and replace it with a new tab for the new node) it just closes the second tab but fails to add the new tab.

I can't see any reason behind it as it is fien adding/removing the tabs when there is just the single tab.

There is an error in FireBug, but it doesn't offer much help:

uncaught exception: [Exception... "Could not convert JavaScript argument arg 0 [nsIDOM3Node.compareDocumentPosition]"  nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)"  location: "JS frame :: /ext/ext-3.1.1/adapter/ext/ext-base-debug.js?d=1066331810 :: <TOP_LEVEL> :: line 1900"  data: no]

-----------UPDATE:--------------

it seems to correlate to doLayout() call - if I put a doLayout() call directly after the remove() call, then it doesnt get as fat as the add() call, and if I put it after the .add() call then it half loads the new tab but stops before completing.

If I have a doLayout() call after both, then it works a little better, and I can then have two functioning tabs, but when I tried to add the third tab it displays the same behaviour as above, and closes the third tab and doesnt repopen a new one..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

断肠人 2024-11-14 02:16:46

我现在已经解决了这个问题 - 问题与我实际添加的 formPanels 有关,而所有面板本身都有唯一的 ID,我没有想过检查表单中其他组件的 ID(正如 Jad 在他的评论中建议的那样) ,并且表单使用静态 ID 定义了“FieldSets”,删除这些就解决了问题。

我还使用开发者工具在 Chrome 中测试了该问题,发现提供的堆栈跟踪比 FireBug 提供的错误有用得多,所以从现在开始我将同时使用两者!

I have now resolved this issue - the problem was to do with the formPanels I was actually adding, whilst all the panels themselves had unique IDs I had not thought to check the IDs of other components within the form (as Jad suggests in his comments), and the forms had "FieldSets" defined with static IDs, removing those resolved the problems.

I also tested the problem in Chrome using the developer tools and found the stack trace provided a lot more useful than the error provided by FireBug, so I will be using both from now on!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文