extjs4 - 存储中批量插入导致性能问题

发布于 2024-12-17 19:41:39 字数 325 浏览 5 评论 0原文

从网格复制行并插入到开头的同一网格中(在位置 0 插入)。

一旦命中超过 10 行,就会导致性能问题。我开始使用

store.suspendEvents(true); foreach(..) { r = ... 商店.插入(0, r); } store.resumeEvents();

它提高了性能,因为网格不再随着存储中的每次插入行而刷新。但是由于某种原因,它在索引存储中的行时会抛出异常。我认为因为商店活动被暂停,所以它的状态有些糟糕。

供参考。它再次在最后添加第二行,并抛出异常消息。

欢迎任何有关如何以其他方式处理这种情况的建议。

Copying the rows from the grid and inserting into same grid in begining (insert at position 0).

It was causing performance issue, as soon as hits more than 10 rows. I started using

store.suspendEvents(true);
foreach(..)
{
r = ...
store.insert(0, r);
}
store.resumeEvents();

It improves a performance, as grid is no longer getting refresh with each insert of row in the store. however for some reason it throws exception while indexing the rows in the store. I think because store events are suspended, its going in some bad state.

fyi. its adding second row in the last again, where it throws with exception message.

Any other suggestion on how to handle this situation in any other way is welcome.

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

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

发布评论

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

评论(1

看透却不说透 2024-12-24 19:41:39

您应该创建一个商店,然后让网格使用该商店。然后,您可以根据需要管理商店,并且数据将自动可供网格使用。像这样的东西:

var the_store = Ext.create('My.store.Foo', { 
    extend: 'Ext.data.Store',
    fields: ['id','name'],
    ...
    proxy: {
        ...
    }
});

var the_grid = Ext.create('My.view.Grid', {
    extend: 'Ext.grid.Panel',
    ...
    store: the_store,
    ...
});

You should create a store and then have the grid use that store. You can then manage the store as needed and the data will automatically be available to the grid. Something like:

var the_store = Ext.create('My.store.Foo', { 
    extend: 'Ext.data.Store',
    fields: ['id','name'],
    ...
    proxy: {
        ...
    }
});

var the_grid = Ext.create('My.view.Grid', {
    extend: 'Ext.grid.Panel',
    ...
    store: the_store,
    ...
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文