首页 > 代码库 > java 基于 bootstrap_datagrid 分页

java 基于 bootstrap_datagrid 分页

1、首先引入datagrid  js ,css

技术分享
$("#datagrid").bootstrap_datagrid({                    url : "<%=path%>/user/findAllUser.html",                    params : {                        page : 1,                        pageSize : 10,                        name:name                    },singleSelect : true,                    pagination:true,                                         columns : [ [   /* {                        title : "userid",                        field : "userid",                        hidden : true,                    },   */ {                        field : ‘name‘,                        title : ‘用户名‘,                    },                    {                        field : ‘telephone‘,                        title : ‘外显号码‘,                    },   {                        field : ‘shortphone‘,                        title : ‘手机号码‘,                    },   {                        field : ‘createtime‘,                        title : ‘创建时间‘,                    },                      {                        field : ‘power‘,                        title : ‘联系人修改权限‘,                        width : 100,                        formatter:function(v,l){                            if(v==0){                                return ‘禁止修改‘;                            } else if(v==1){                                return ‘允许修改‘;                            }                                                     }                    },{                        title : "操作",                        formatter:function(v,l){                            var c=‘<a href="javascript:void(0);" onclick="showedit(‘+l.userid+‘)" title="编辑"><span class="fa fa-edit" aria-hidden="true"></span></a>‘;                            c+=‘&nbsp;&nbsp;<a href="javascript:void(0);" onclick="showDel(‘+l.userid+‘)" title="删除"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></a>‘;                            return c;                        }                    }                      ] ]                                });
View Code
技术分享
@RequestMapping("findAllUser")    public void findAccount(HttpServletRequest req,HttpServletResponse res,int page,int pageSize,String name) throws Exception{                Domain domain = (Domain) req.getSession().getAttribute("Domainlogin");        Page<Users> list = userservice.findAllUser(domain.getDomainid(),name, page, pageSize);                        SimpleFilterProvider sfp = new SimpleFilterProvider();        sfp.addFilter("userFilter",SimpleBeanPropertyFilter.serializeAllExcept("rechargerecords"));            String json = JacksonUtil.objToJson(list, sfp);        writeString(json, res);                    }
View Code
技术分享
@Override    public Page<Users> findAllUser(long domainid, String name,int page, int pageSize) {                String hql=null;        if(name==null){            hql="from Users u where u.domainid="+domainid;        }else{            hql="from Users u where u.domainid="+domainid+" and lower(u.name) like ‘%"+name+"%‘";        }        Page<Users> page1 = new Page<Users>();        page1.setRows(dao.getEntityList(hql.toString()+" order by createtime desc", pageSize, page));        page1.setPage(page);        page1.setTotalCount(dao.countByHql("select count(u.userid) " + hql));        return page1;    }
View Code

2.用到的实体、封装的方法详见 百度云  http://pan.baidu.com/s/1dE8jNxB      http://pan.baidu.com/s/1qYTIsCs

java 基于 bootstrap_datagrid 分页