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

2022-12-10,,,,

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

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

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

 function _3e(_44,_45){
//for(var i=0;i<_45.length;i++){
////var tr1=$(_44[i]);
////var tr2=$(_45[i]);
////tr1.css("height","");
////tr2.css("height","");
////var _46=Math.max(tr1.height(),tr2.height());
////tr1.css("height",_46);
////tr2.css("height",_46);
//}
};

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

 function scrolling(){
if (getDataHeight() < dc.body2.height() && view.renderedCount < state.data.total){
this.getRows.call(this, target, function(rows){
this.rows = rows;
this.populate.call(this, target);
dc.body2.triggerHandler('scroll.datagrid');
});
} else if (dc.body2.scrollTop() >= getDataHeight() - dc.body2.height()) {
// 注释掉下面代码是为了滚动时不加载下一页数据
//this.getRows.call(this, target, function(rows){
// this.rows = rows;
// this.populate.call(this, target);
//});
}
}

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

EasyUI 1.4.4 DataGrid(大数据量) bufferview滚动时不加载下一页数据解决方案的相关教程结束。

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

下载本文的Word格式文档,以方便收藏与打印。