日期:2014-05-16  浏览次数:20349 次

Extjs使用技巧之,大数据量Grid做数据移除和添加效率优化


慢的原因:

因为每一次从Store中移除一条数据,Grid都会进行重画,当数据量比较大的时候,需要的时间会很长,例如在1500条Grid中移除1条可能需要2秒左右,移除10条就需要10多秒,移除800条,谷歌浏览器就有崩溃的嫌疑。


解决思路:

1、先禁用掉Ext的重绘,等删除完成后在恢复重绘功能,代码如下

                                Ext.suspendLayouts();
				store.remove(selection);
				Ext.resumeLayouts(true);

2、先禁用掉Store的事件,等处理完成后,恢复,再将store重新指定给Grid,代码如下
store.suspendEvents();
store.remove(selection);
                        store.resumeEvents();grid.reconfigure(store);


3、两者结合
                        Ext.suspendLayouts();
store.suspendEvents();
store.remove(selection);
store.resumeEvents();
grid.reconfigure(store);
Ext.resumeLayouts(true);