JQuery EasyUI Grid 分页



以下示例使用JQuery Easy UI、Spring MVC:

首先定义一个DataGrid:

01 $('#tt').datagrid({
02                     fit:true,
03                     pageNumber:1,
04                     pageList:[10,20,50],
05                     url:'${pageContext.request.contextPath}/branch_office/list/json.htm',
06                     nowrap: false,
07                     striped: true,
08                     collapsible:true,
09                     remoteSort: false,
10                     columns:[[
11                             {title:'名称',field:'name',width:300,sortable:true,sorter:function(a,b){ return (a>b?1:-1);}},
12                             {title:'创建时间',field:'createTime',width:150,sortable:true,sorter:function(a,b){ return(a>b?1:-1);}},
13                             {title:'修改时间',field:'modifyTime',width:150,sortable:true,sorter:function(a,b){ return(a>b?1:-1);}}
14                         ]],
15  
16                     pagination:true,
17                     singleSelect:true,
18                     rownumbers:true
19                 });
在Spring MVC 的Controller 中的方法,返回Json格式的数据:

01 @RequestMapping(value = "/branch_office/list/json", method = RequestMethod.POST)
02     public
03     @ResponseBody
04     Map<String, Object> getJson(int page, int rows, Map<String, Object> map) {
05         //DataGrid 会向 请求Json 的地址以POST方法发送2个参数:page(当前页码)和rows(每页显示记录数)
06         //获取分页数据
07         List<BranchOfficeViewObject> branchOfficeVOList = iBranchOfficeService.showList(page, rows);
08  
09         //获取总记录数
10         int totalRows = iBranchOfficeService.getTotalRows();
11  
12         map.put("total", totalRows);
13         map.put("rows", branchOfficeVOList);
14  
15         //返回指定格式的Map,Jackson会把Map转换未Json
16         return map;
17     }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值