JS组件Bootstrap Table使用实例分享
学习使用bootstrap表格是对客户端进行分页的时候,在朋友的帮助下,找到了文档http://bootstrap-table.wenzhixin.net.cn/examples/
找到了传到后台的每页条数Limit,和记录开始数Offset。
开始封装,分享一下我的代码,从bootstraptable获取页码和页数,并交给后台处理。
$('#table').bootstrapTable({
url:'<%=path%>/FeedList.cqzk',
striped:true,
pagination:true,
pageList:[3,5,20],
pageSize:3,
pageNumber:1,
sidePagination:'server',//设置为服务器端分页
columns:[{
field:'title',
title:'标题'
},{
field:'creatTime',
title:'时间'
}]
});
@RequestMapping(value="/FeedList.cqzk")
@ResponseBody
publicStringurl_ad1(HttpServletRequestrequest,BootPagepage)
throwsServletException,IOException,RuntimeException{
@SuppressWarnings("unchecked")
//List<Feedback>list=feedBackDao.find("fromFeedback");
BootPagepager=feedBackDao.getByPage("fromFeedback",page,null);
System.out.println((JSONArray.fromObject(pager)).getString(0).toString());
return(JSONArray.fromObject(pager)).getString(0).toString();
//不写.getString(0)就多一个中括号,返回的就是数组,写了就是返回第一个对象。
}
publicBootPagegetByPage(Stringhql,BootPagepager,Map<String,Object>condition){
if(pager==null){
thrownewIllegalArgumentException("分页不能为空!");
}
Queryq=sessionFactory.getCurrentSession().createQuery(hql);
q.setFirstResult(pager.getOffset());
q.setMaxResults(pager.getLimit());
if(condition!=null){
q.setProperties(condition);
}
pager.setRows(q.list());
pager.setTotal(this.countAll(hql,condition));
returnpager;
}
protectedLongcountAll(Stringhql,Map<String,Object>condition){
if(hql==null){
return0l;
}
StringtmpHql=hql.toLowerCase();
Stringregex=hql.substring(0,tmpHql.indexOf("from"));
hql=hql.replaceFirst(regex,"selectcount(*)");
Queryq=sessionFactory.getCurrentSession().createQuery(hql);
if(condition!=null){
q.setProperties(condition);
}
return(Long)q.uniqueResult();
}
publicfinalclassBootPage<T>{
protectedLongtotal;
protectedList<T>rows;
protectedintlimit=0;
protectedintoffset=0;
protectedStringorder="asc";
如果大家还想深入学习,可以点击这里进行学习,再为大家附3个精彩的专题:
Bootstrap学习教程
Bootstrap实战教程
Bootstrap插件使用教程
以上就是为大家分享的BootstrapTable使用方法,希望对大家熟练掌握BootstrapTable使用方法有所帮助。
热门推荐
1 训练狗狗憋尿
2 狗狗追踪训练
3 狗狗训练要多少钱
5 深圳狗狗训练
6 训练狗狗唤回
7 狗狗叫怎么训练
8 狗狗训练班
10 狗狗社会化训练
11 狗狗叫回训练
12 广州狗狗训练学校
13 狗狗训练躺下
14 狗狗随行训练
15 训练狗狗巡回
16 狗狗要怎么训练
17 狗狗喂食训练
18 训练狗狗躺下