extJS:将 grid.Panel 从控制器添加到视图会导致应用程序挂起(MVC)

发布于 2024-12-11 21:46:56 字数 1511 浏览 0 评论 0 原文

我正在尝试动态创建 grid.Panels 并将它们添加到我的视图中,因为我不知道在加载数据之前需要多少“视图”。例如,我有很多人在不同的组中,一旦加载数据,我想为每个组创建一个 grid.Panel 并将正确的人放入其中。

问题是我的应用程序在执行此操作时挂起(可能是因为存储正在递归加载)

如何将 grid.Panel 添加到我的视图,其中包含存储中的数据而不挂起?

我的控制器:

Ext.define('NG.controller.Navigation', {
    extend: 'Ext.app.Controller',

    refs: [{
        selector: 'group',
        ref: 'groupPanel'}
    ],

    stores: ['Groups'],

    init: function() {
         this.control({
            'navigation': {
                itemdblclick: this.onNavigationSelection
            }
        });
    },
    onNavigationSelection: function(view, record, item, index, eventobj, obj) {

        var groupsstore = this.getGroupsStore();

        var group1 = Ext.create('Ext.grid.Panel', {
            store: groupsstore,
            title: 'Group 1',
            columns: [
                    {header: 'Name', dataIndex: 'name'},
                    {header: 'Mail:',  dataIndex: 'mail'}
            ]
        });

        groupsstore.load();

        this.getGroupPanel().add(group1);
    }
});

我的视图:

Ext.define('NG.view.Group', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.group',
    store: 'Groups',
    initComponent: function() {
        this.callParent();
    }
});

和我的商店(不确定是否需要):

Ext.define('NG.store.Groups', {
    extend: 'Ext.data.Store',
    requires: 'NG.model.Person',
    model: 'NG.model.Person'
});

谨致问候并提前感谢您!

安德烈亚斯

I am trying to dynamically create grid.Panels and add them to my View, since I don't know have many "Views" I need before I load the data. For example, I have a number of people in different groups, once I load the data, I want to create a grid.Panel for each group and put the correct people in it.

The problem is that my application hangs when I do it (probably because the Store is being loaded recursively)

How do I add a grid.Panel to my View with data from a Store without it hanging?

My Controller:

Ext.define('NG.controller.Navigation', {
    extend: 'Ext.app.Controller',

    refs: [{
        selector: 'group',
        ref: 'groupPanel'}
    ],

    stores: ['Groups'],

    init: function() {
         this.control({
            'navigation': {
                itemdblclick: this.onNavigationSelection
            }
        });
    },
    onNavigationSelection: function(view, record, item, index, eventobj, obj) {

        var groupsstore = this.getGroupsStore();

        var group1 = Ext.create('Ext.grid.Panel', {
            store: groupsstore,
            title: 'Group 1',
            columns: [
                    {header: 'Name', dataIndex: 'name'},
                    {header: 'Mail:',  dataIndex: 'mail'}
            ]
        });

        groupsstore.load();

        this.getGroupPanel().add(group1);
    }
});

My View:

Ext.define('NG.view.Group', {
    extend: 'Ext.panel.Panel',
    alias: 'widget.group',
    store: 'Groups',
    initComponent: function() {
        this.callParent();
    }
});

And my Store (not sure if it is needed):

Ext.define('NG.store.Groups', {
    extend: 'Ext.data.Store',
    requires: 'NG.model.Person',
    model: 'NG.model.Person'
});

Best regards and thank you in advance!

Andreas

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

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

发布评论

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

评论(2

撩心不撩汉 2024-12-18 21:46:56

浏览完每个参考资料后,我在代码中找不到任何错误。不过,我发现了有关类似问题的错误报告:

http://www.sencha.com/forum/showthread.php?141804-4.0.5-Grid-Uncaught-RangeError-Maximum-call-stack-size-exceeded

我下载了上周框架,几天前有一个更新,解决了这个错误和我的问题。

感谢您的帮助!

After walking through each reference I could not find any errors in the code. However I found a bug report about a similar problem:

http://www.sencha.com/forum/showthread.php?141804-4.0.5-Grid-Uncaught-RangeError-Maximum-call-stack-size-exceeded

I downloaded the Framework last week, and there was an update a few days ago, which solved this bug and my problem as well.

Thank you for your help!

猫性小仙女 2024-12-18 21:46:56

store.load() 事件是异步的。
尝试切换添加面板和加载存储事件:

this.getGroupPanel().add(group1);
groupsstore.load();

另一件事是,您似乎没有将任何内容传递给存储来加载它。因此,您可以自动加载它并提前准备好数据。

The store.load() event is asynchronous.
Try switching the add panel and load store events around:

this.getGroupPanel().add(group1);
groupsstore.load();

The other thing is it doesn't look like you are passing anything to the store to load it. So you can just autoload it and have the data ready ahead of time.

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