DataSet客户端分页实现

window.$ClientPageHelper=function(fromDs,toDs){
	var pageSize=toDs.get('pageSize');
	var elist=fromDs.getData();
	var entityCount=elist.entityCount;
	var pageCount=parseInt((entityCount-1)/pageSize)+1;
        var pageList=new dorado.EntityList();
	var datas=elist.toArray();
	for(var pi=0;pi<pageCount;pi++){
	var page=new dorado.EntityList.Page(pageList, pi+1);
        var start=pi*pageSize;
	var max=(pi+1)*pageSize;
	for(var no=start;no<max;no++){
	     var e=datas[no];
	     if(e){
		page.insert(e);
	      }
	}
	pageList._pages.insert(page);
	}
        pageList.pageSize=pageSize;
        pageList.entityCount=entityCount;
        pageList.pageCount=pageCount;
        toDs.setData(pageList);
}

  

posted @ 2017-01-03 11:51  ACaptain  阅读(516)  评论(0编辑  收藏  举报