EasyUI 1.4.4 DataGrid(大数据量) bufferview滚动时不加载下一页数据解决方案

  在使用Easyui DataGrid 过程中,发现若单页数据量超过300,IE浏览器加载速度很慢。也通过网上找寻了很多解决方案,最典型的就是去掉datagrid的自动列宽以及自动行高判断。

  1、解决自动列宽:  设定列宽度可解决。

  2、解决自动行高 : 注释掉下面的代码。

 1 function _3e(_44,_45){
 2 //for(var i=0;i<_45.length;i++){
 3 ////var tr1=$(_44[i]);
 4 ////var tr2=$(_45[i]);
 5 ////tr1.css("height","");
 6 ////tr2.css("height","");
 7 ////var _46=Math.max(tr1.height(),tr2.height());
 8 ////tr1.css("height",_46);
 9 ////tr2.css("height",_46);
10 //}
11 };

  使用上述两种解决办法后,加载速度有所改观,但效果不是很明显。后来使用了datagrid的scrollview和bufferview视图,scrollview效果仍然不太好,但使用了bufferview后,效果相当明显,最终选定使用bufferview来加载单页数据,速度虽然解决了,遇到了另外一个问题,原有的DataGrid做了分页处理,bufferview在滚动条拉到最底部时候,会自动加载下一页数据,我已经有了对datagrid的分页处理,所以这个功能不需要,经多次尝试,解决方案如下:

 1 function scrolling(){
 2             if (getDataHeight() < dc.body2.height() && view.renderedCount < state.data.total){
 3                 this.getRows.call(this, target, function(rows){
 4                     this.rows = rows;
 5                     this.populate.call(this, target);
 6                     dc.body2.triggerHandler('scroll.datagrid');
 7                 });
 8             } else if (dc.body2.scrollTop() >= getDataHeight() - dc.body2.height()) {
 9                 //  注释掉下面代码是为了滚动时不加载下一页数据
10                 //this.getRows.call(this, target, function(rows){
11                 //    this.rows = rows;
12                 //    this.populate.call(this, target);
13                 //});
14             }
15         }

  将scrolling方法中的else if 里面的代码块注释掉就可以了。

posted @ 2016-06-20 11:37  追逐者——Eagle  阅读(3513)  评论(0编辑  收藏  举报