国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS組件Bootstrap Table使用實例分享

2019-11-20 09:51:43
字體:
來源:轉載
供稿:網友

學習使用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" ;

如果大家還想深入學習,可以點擊這里進行學習,再為大家附3個精彩的專題:

Bootstrap學習教程

Bootstrap實戰教程

Bootstrap插件使用教程

以上就是為大家分享的Bootstrap Table使用方法,希望對大家熟練掌握Bootstrap Table使用方法有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 阿合奇县| 石城县| 高密市| 宽城| 斗六市| 夹江县| 昌邑市| 嘉定区| 徐水县| 赤城县| 遂川县| 饶阳县| 株洲县| 霍林郭勒市| 剑川县| 平潭县| 汝城县| 合作市| 莱芜市| 清远市| 曲松县| 安国市| 永州市| 吉林省| 齐齐哈尔市| 济宁市| 滁州市| 杭州市| 和田县| 怀集县| 广州市| 泰宁县| 广宁县| 雅安市| 正镶白旗| 政和县| 霍山县| 天镇县| 永吉县| 彭阳县| 恩施市|