Front-end part:
Ext.define('GS.system. role.store.RoleGridStore',{
extend:'Ext.data.Store',
model:'GS.system.role.model.RoleGridModel',
id:'roleStoreId',
pageSize:4,//Page 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
}],
autoLoad:{start: 0, limit: 4}//start is the number of items to start from, limit is the number of items per page
});
store.loadPage(1); //Load the first page
Backend part:
private int limit;//Number of items on each page
private int start;//Which piece of data to start checking
private int total;//Total number of items
/**
* Find all characters
*/
public void getRoleList()
{
List roleList=new ArrayList() ;
StringBuffer toJson=new StringBuffer();//Used to put json data
System.out.println(start "," limit "," total);
try
{
roleList=(List) 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{
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{
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();
}
}