The application of pagination in EXTJS4

Source: Internet
Author: User
Tags json tojson stringbuffer

  This article describes how to use the pagination in the next Extjs4 and combine front and rear, specific examples such as, interested friends can refer to the following

The front section:  code is as follows: Ext.define (' GS.system.role.store.RoleGridStore ',{  extend: ' Ext.data.Store ',  model: ' GS.system.role.model.RoleGridModel ',  ID: ' Rolestoreid ',  pagesize:4,//paging size   proxy:{  type: ' Ajax ',  URL: '/gs_erp/roleaction!getrolelist ',  reader: {  type: ' JSON ',  root: ' Rows ',  Totalproperty: ' Total '  } },  sorters: [{  property: ' ID ',///Sort field   Direction: ' ASC '//default Asc&nbs P }],  autoload:{start:0, Limit:4}//start is starting from the first few, limit is the number of pages per page  });    store.loadpage (1); Load first page   Background section:  code as follows: Private int limit;//The number of bars   private int start;//from which data to check   private int total;// Total number  /**  * Find all roles   */  public void getrolelist ()   {    list<role> rolelist=new A Rraylist<role> ();  stringbuffer tojson=new stringbuffer ()//To put JSON data   SYSTEM.OUT.PRINTLN (start+) "+limit+", "+total";  try  {  rolelist= (list<role>) PAGeserviceimpl.commonpagination (Role.class, "", Start, limit);  Total=pageserviceimpl.gettotalnum (Role.class, " ");  Tojson.append (" {total: "). Append (" +total+ "). Append (", Success:true, "). Append (" Start: ")   Append (" "+start+"). Append (",");  tojson.append ("rows:[");  for (int i=0;i<rolelist.size (); i++)   {  Tojson.append ("{ID:"). Append (""). Append ("" +rolelist.get (i) getId () + ""). Append ("")  . Append (", Name:"). Append (""). Append ("" "+rolelist.get (i) getName () +" ")   Append (" ' "). Append (", desc: "). Append (" ") Rolelist.get (i). GetDesc () + "")   Append ("'"). Append ("}");  if (I<rolelist.size ()-1)   {  Tojson.append (","); } }  tojson.append ("]}"; } catch (Exception E1)   { //TODO Auto-ge Nerated catch block  e1.printstacktrace (); }  try  {  response.setheader ("Cache-Control", " No-cache ");  response.setcontenttype (" Text/json;charset=utf-8 ");  Response.getwriter(). Print (Tojson);  System.out.println (Tojson); } catch (IOException e)   { //TODO auto-generated Catch block  e.printstacktrace (); } }     

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.