{“code”:”005″,”name”:”Name 5″,”addr”:”Address 45″,”col4″:”col4 data”},
{“code”:”006″,”name”:”Name 6″,”addr”:”Address 16″,”col4″:”col4 data”},
{“code”:”007″,”name”:”Name 7″,”addr”:”Address 27″,”col4″:”col4 data”},
{“code”:”008″,”name”:”Name 8″,”addr”:”Address 81″,”col4″:”col4 data”},
{“code”:”009″,”name”:”Name 9″,”addr”:”Address 69″,”col4″:”col4 data”},
{“code”:”010″,”name”:”Name 10″,”addr”:”Address 78″,”col4″:”col4 data”}
]
}
这里呢,后台传递数据很重要:
注意:表格Post或者get回来的请求中
page:3 代表page为key,然后选择的当前页码为3
rows:10 代表一页的大小为10
后台返回的数据的格式为:{total:”,rows:[{},{}]}
只要包含了总数tatol字段,rows是具体的行数
例如:
Asp.Net MVC 例子:
public JsonResult GetAllUserInfos()
{
int pageSize = 5;
int pageIndex = 1;
int.TryParse(this.Request[“page”], out pageIndex);
int.TryParse(this.Request[“rows”], out pageSize);
pageSize = pageSize <= 0 ? 5 : pageSize;
pageIndex = pageIndex < 1 ? 1 : pageIndex;
var temp = db.UserInfo
.OrderBy(u=>u.Sort)
.Skip<UserInfo>((pageIndex-1)*pageSize)
.Take<UserInfo>(pageSize)
.ToList<UserInfo>();
Hashtable ht = new Hashtable();
ht[“total”] = db.UserInfo.Count();
ht[“rows”] = temp;
return Json(ht);
}
Asp.Net WebForm 例子:
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = “text/plain”;
var strWebName = context.Request[“WebName”] ?? string.Empty;
var GoodsNo = context.Request[“GoodsNo”] ?? string.Empty;
int categoryId = 0;
int pageIndex = 1;
int pageSize = 10;
int.TryParse(context.Request[“rows”], out pageSize);
int.TryParse(context.Request[“page”], out pageIndex);
decimal priceLeft = 0;
decimal priceRight = 1000000;
int goodsStatus = 0;
decimal.TryParse(context.Request[“PriceLeft”], out priceLeft);
decimal.TryParse(context.Request[“PriceRight”], out priceRight);
int.TryParse(context.Request[“CategoryId”], out categoryId);
int.TryParse(context.Request[“GoodsStatus”], out goodsStatus);
var goodsQueryParamter = new GoodsQueryParamter();
goodsQueryParamter.GoodsStatus = (Model.GoodsModel.GoodsStatusEnum)goodsStatus;










