当前位置:首页 > 开发 > 编程语言 > NoSQL > 正文

java jquery mongodb/mysql 分页

发表于: 2014-03-18   作者:annan211   来源:转载   浏览次数:
摘要: java 分页 页面函数 function searchHistory(page,disR){ var fn = arguments.callee; var req = $('#f_1').serialize() + '&page='+(page||1)+'&displayRecord='+(disR=disR||10)+"&
java 分页
   页面函数 
   function searchHistory(page,disR){
		var fn = arguments.callee;
		var req = $('#f_1').serialize() + '&page='+(page||1)+'&displayRecord='+(disR=disR||10)+"&replyCode="+1 + "&ran="+Math.random();//默认10
		$.post("/data/listDistributorInfos.do", req, function(json) {
			if(json.success !== true){
				//提示报错
				alert(json.message);
			} else{
				var count 	= json.object.count,
				list 		= json.object.lists,
				p 			= json.object.page,
				pCount 		= json.object.pageCount;

				var $tbody = $('#J_tbody'), $box = $('#box');
				var html = '';
				$.each(list,function(i,n){
					var status_class = "";
					if(n.status == 1){
						status_class = "closed";
					}
					var time1 = "";
					if(n.createTime != null){
						var temp = new Date(n.createTime);
						time1 = temp.Format("yyyy-MM-dd");
					}
					var text = "<tr class='" + status_class + "'>"+
					"<td><a href='/gift/giftView.jspx?id=" + n.distributor_name +"'>"+  n.distributor_name  + "</a>"+'</td>' +
					'<td>'+n.deposit_num+'</td>'+
					'<td>'+222+'</td>'+
					'<td>'+n.activation_num+'</td>'+
					'<td>'+n.trading_num+'</td>'+
					'<td>'+n.distributor_gift_id+'</td>'+
					"<td><a href=\"/distributor/viewAndEditDistributor.jspx?distributor_name=" + n.distributor_name + "\">详细</a></td>"+
					'</tr>';
					if(null != text && text != ""){
						html += text;
					}
				});
				$tbody.html(html);
				var sort = $('#tr_head').find('td')
				//$('#count').html(" | 记录数("+count+")");

				//分页
				var $pag=$box.find('.paginationbar'),$dis=$box.find('.displayNum');
				$.sysop.pagination.init($pag,p,pCount,10,function(num){
					fn(num,disR);
				});
				//显示数目
				$.sysop.pagination.displayNum($dis,disR,function(){
					fn(1,this.innerHTML.slice(0,-1));
				});
			}
		});
	}


	$('#searchF').bind('click',function(){
		searchHistory(undefined,$.crm.getPageSize(), true);
	});
	$(function(){
		backAutoFillForm.init('#searchF','#f_1');// 提交按钮 表单
		searchPrize();
	});

	$('#add').bind('click',function(){
		window.location="/distributor/addDistributor.jspx";
	});
$.sysop 一类函数详见 附件 jquery.sysop.zip 


  mysql 分页controller
  @MethodResourceDesc(name = "[data]获取代理商列表")
	@RequestMapping(value = "/data/listDistributorInfos.do")
	@ResponseBody
	public Result listAdvertisSet(HttpServletRequest request,HttpServletResponse response){
		Result result = new Result();
		try{
			/*Query query = CRMQueryHelper.makeDistributorInfoQuery(
					RequestHelper.getQueryFields(request, CommercialDistributor.DISTRIBUTOR_NAME),
					 CommercialDistributor.CREATE_TIME, Order.DESCENDING);*/

			//int allCount = (int)commercialDistributorService.allCount(query);
			int pageSize = RequestHelper.getPageSize(request);
			if(0 == pageSize){
				pageSize = 20;
			}

//			List<CommercialDistributor> list = distributorInfoService.list(
//					query.skip(
//							(RequestHelper.getPageIndex(request) - 1) * pageSize
//							).limit(pageSize));
			Map<String,Object> map = new HashMap<String,Object>();
			map.put("page", (RequestHelper.getPageIndex(request) - 1) * pageSize);
			map.put("pageSize", pageSize);
			map.put("distributorName", RequestHelper.getQueryFields(request, "distributorName"));
			List<DistributorConsumeResult> list = commercialDistributorService.listCommercialDistributor(map);
			/*List<CommercialDistributor> list = commercialDistributorService.list(
					query.skip(
							(RequestHelper.getPageIndex(request) - 1) * pageSize
							).limit(pageSize));*/

			int allCount = (int)commercialDistributorService.allCount();

			PagingVO pagingObject = new PagingVO();
			pagingObject.setPageCount((allCount + pageSize) / pageSize);
			pagingObject.setPage(RequestHelper.getPageIndex(request));
			pagingObject.setCount(allCount);
			pagingObject.setLists(list);
			result.setCode(ResultCode.SUCCESS);
			result.setObject(pagingObject);

		}catch(Exception e){
			result.setMessage(e.getMessage());
			logger.error(e.getMessage());
		}
		return result;
	}


mongodb 分页 controller 
  @MethodResourceDesc(name = "[data]获取代理商列表")
	@RequestMapping(value = "/data/listDistributorInfos.do")
	@ResponseBody
	public Result listAdvertisSet(HttpServletRequest request,HttpServletResponse response){
		Result result = new Result();
		try{
			Query query = CRMQueryHelper.makeDistributorInfoQuery(
					RequestHelper.getQueryFields(request, CommercialDistributor.DISTRIBUTOR_NAME),
					 CommercialDistributor.CREATE_TIME, Order.DESCENDING);*/

			int allCount = (int)commercialDistributorService.allCount(query);
			int pageSize = RequestHelper.getPageSize(request);
			if(0 == pageSize){
				pageSize = 20;
			}
			
			List<CommercialDistributor> list = commercialDistributorService.list(
					query.skip(
							(RequestHelper.getPageIndex(request) - 1) * pageSize
							).limit(pageSize));

			PagingVO pagingObject = new PagingVO();
			pagingObject.setPageCount((allCount + pageSize) / pageSize);
			pagingObject.setPage(RequestHelper.getPageIndex(request));
			pagingObject.setCount(allCount);
			pagingObject.setLists(list);
			result.setCode(ResultCode.SUCCESS);
			result.setObject(pagingObject);

		}catch(Exception e){
			result.setMessage(e.getMessage());
			logger.error(e.getMessage());
		}
		return result;
	}

result PagingVO 详见 Result_PagingVO


java jquery mongodb/mysql 分页

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
本文是struts2+jquery-ajax实现的在mySQL下的高效分页 1:先看下预览效果:(30多万数据测试) 2:这个实
转自:http://coding4fun.sinaapp.com/?p=23 1、首先引入easyui包,可以在官方网站下载,http://www
jQuery+Ajax+PHP+Mysql实现分页显示数据 就2个文件,一个显示分页的文件和一个获取分页的文件 本例
本文是struts2+jquery-ajax实现的在mySQL下的高效分页 1:先看下预览效果:(30多万数据测试) 2:这个实
MongoDb的一个应用方案,具体场景是,框架是 Play1.x后端+Delphi前端,查询是数据过多,所以有用缓
【MongoDB for Java】Java操作MongoDB 上一篇文章: http://www.cnblogs.com/hoojo/archive/2011/06/
开发环境: System:Windows IDE:eclipse、MyEclipse 8 Database:mongoDB 开发依赖库: JavaEE5、
开发环境: System:Windows IDE:eclipse、MyEclipse 8 Database:mongoDB 开发依赖库: JavaEE5、
上一篇文章: http://www.cnblogs.com/hoojo/archive/2011/06/01/2066426.html介绍到了在MongoDB的控
开发环境: System:Windows IDE:eclipse、MyEclipse 8 Database:mongoDB 开发依赖库: JavaEE5、
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号