JS Component Bootstrap table use instances to share _javascript tips

Source: Internet
Author: User

Learn to use the bootstrap table when paging the client, with the help of a friend, find the document http://bootstrap-table.wenzhixin.net.cn/examples/                 &NBSP
Found the number of limit per page that was uploaded to the background, and the number of records started offset.             &NBSP
Start encapsulation, share my code, from bootstrap Table gets the page numbers and pages, and gives the background processing.

$ (' #table '). bootstraptable ({url: ' <%=path%>/feedlist.cqzk ', Striped:true, Pagination:true, PageList: [3,
  5,20], Pagesize:3, pagenumber:1, sidepagination: ' Server ',//set to server-side paging columns: [{field: ' titles ', Title: ' Title '



 }, {field: ' Creattime ', title: ' Time '}]}; @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 ();
 Do not write. getString (0) One more bracket, return is an array, write is to return the first object. Public Bootpage getbypage (String hql,bootpage pager,map<string, object> condition) {if (pager = null) {th Row new IllegalArgumentException ("pagination cannot beis empty! ");}
 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;
 
 protected list<t> rows;
 
 protected int limit=0;
 
 protected int offset = 0;
 protected String order = "ASC";

If you want to further study, you can click here to learn, and then attach 3 wonderful topics:

Bootstrap Learning Course

Bootstrap Practical Course

Bootstrap Plugin Usage Tutorial

The above is for everyone to share the use of bootstrap table, I hope to master the use of bootstrap table is helpful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.