Combining paging applications in Extjs4 with the front and back ends

Source: Internet
Author: User

Combining paging applications in Extjs4 with the front and back ends

This article describes how to use pages in Extjs4 in combination with the front and back ends. The specific example is as follows. If you are interested, refer

Foreground:

The Code is as follows:

Ext. define ('gs. system. role. store. rolegridstore ',{

Extend: 'ext. data. store ',

Model: 'gs. system. role. model. RoleGridModel ',

Id: 'Role storeid ',

PageSize: 4, // page size

Proxy :{

Type: 'ajax ',

Url: '/gs_erp/roleAction! GetRoleList ',

Reader :{

Type: 'json ',

Root: 'rows ',

TotalProperty: 'Total'

}

},

Sorters :[{

Property: 'id', // sorting Field

Direction: 'asc '// default asc

}],

AutoLoad: {start: 0, limit: 4} // start indicates the number of entries on each page.

});

 

Store. loadPage (1); // load the first page

Background:

The Code is as follows:

Private int limit; // number of entries per page

Private int start; // the data from which the query starts.

Private int total; // The total number of items.

/**

* Search for all roles

*/

Public void getRoleList ()

{

 

List <Role> roleList = new ArrayList <Role> ();

StringBuffer toJson = new StringBuffer (); // used to store 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 ("'"). append ("" + roleList. get (I ). getDesc () + "")

. Append ("'"). append ("}");

If (I <roleList. size ()-1)

{

ToJson. append (",");

}

}

ToJson. append ("]}");

} Catch (Exception e1)

{

// TODO Auto-generated 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.