您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

JS组件Bootstrap Table使用实例分享

2024/6/28 17:00:47发布34次查看
学习使用bootstrap表格是对客户端进行分页的时候,在朋友的帮助下,找到了文档http://bootstrap-table.wenzhixin.net.cn/examples/
找到了传到后台的每页条数limit,和记录开始数offset。
开始封装,分享一下我的代码,从bootstrap table 获取页码和页数,并交给后台处理。
$('#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 public string url_ad1(httpservletrequest request,bootpage page) throws servletexception,ioexception,runtimeexception{ @suppresswarnings("unchecked") // list<feedback> list = feedbackdao.find("from feedback"); bootpage pager = feedbackdao.getbypage("from feedback",page,null); system.out.println((jsonarray.fromobject(pager)).getstring(0).tostring()); return (jsonarray.fromobject(pager)).getstring(0).tostring(); // 不写.getstring(0) 就多一个中括号,返回的就是数组,写了就是返回第一个对象。 } public bootpage getbypage(string hql,bootpage pager,map<string, object> condition){ if (pager == null) { throw new illegalargumentexception("分页 不能为空!"); } query q = 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)); return pager; } protected long countall(string hql, map<string, object> condition) { if (hql == null) { return 0l; } string tmphql = hql.tolowercase(); string regex = hql.substring(0, tmphql.indexof("from")); hql = hql.replacefirst(regex, "select count(*) "); query q = sessionfactory.getcurrentsession().createquery(hql); if (condition != null) { q.setproperties(condition); } return (long) q.uniqueresult(); } public final class bootpage<t> { protected long total; protected list<t> rows; protected int limit=0; protected int offset = 0; protected string order ="asc" ;
以上就是为大家分享的bootstrap table使用方法,希望对大家熟练掌握bootstrap table使用方法有所帮助。
更多js组件bootstrap table使用实例分享。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product