Share JS component BootstrapTable with Instances

Source: Internet
Author: User
This article describes in detail how to use the JS component BootstrapTable pagination, which is practical. If you are interested, you can refer to learning to use the bootstrap table when paging the client, with the help of a friend, I found the document http://bootstrap-table.wenzhixin.net.cn/examples/
The number of lines on each page uploaded to the background is Limit, and the number of records starting Offset is found.
Start encapsulation, share my code, get the page number and page number from the bootstrap table, and hand it to the background for processing.

$ ('# Table '). bootstrapTable ({url: '<% = path %>/FeedList. cqzk ', striped: true, pagination: true, pageList: [3, 5, 20], pageSize: 3, pageNumber: 1, sidePagination: 'server ', // set it to server-side paging columns: [{field: 'title', 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
 
  
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) has one more square brackets, and returns an array. If it is written, it returns the first object. } Public BootPage getByPage (String hql, BootPage pager, Map
  
   
Condition) {if (pager = null) {throw new IllegalArgumentException ("the page cannot be blank! ");} 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
   
    
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
    
     
{Protected Long total; protected List
     
      
Rows; protected int limit = 0; protected int offset = 0; protected String order = "asc ";
     
    
   
  
 

The above is the Bootstrap Table usage method shared for you. It is helpful for you to master the Bootstrap Table usage method.

For more articles about how to use the JS component Bootstrap Table to share instances, refer to PHP!

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.