Extjs4中的分頁(yè)應(yīng)用結(jié)合前后臺(tái)
Ext.define('GS.system.role.store.RoleGridStore',{
extend:'Ext.data.Store',
model:'GS.system.role.model.RoleGridModel',
id:'roleStoreId',
pageSize:4,//分頁(yè)大小
proxy:{
type:'ajax',
url:'/gs_erp/roleAction!getRoleList',
reader: {
type: 'json',
root: 'rows',
totalProperty: 'total'
}
},
sorters: [{
property: 'id', //排序字段
direction: 'asc'// 默認(rèn)ASC
}],
autoLoad:{start: 0, limit: 4}//start是從第幾條開(kāi)始,limit是每頁(yè)的條數(shù)
});
store.loadPage(1); //加載第一頁(yè)
后臺(tái)部分:
private int limit;//每一頁(yè)的條數(shù)
private int start;//從哪一條數(shù)據(jù)開(kāi)始查
private int total;//總條數(shù)
/**
* 查找所有角色
*/
public void getRoleList()
{
List<Role> roleList=new ArrayList<Role>();
StringBuffer toJson=new StringBuffer();//用來(lái)放json數(shù)據(jù)
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();
}
}
相關(guān)文章
Extjs 繼承Ext.data.Store不起作用原因分析及解決
有關(guān)Extjs 繼承Ext.data.Store 不起作用的原因有很多種,接下來(lái)與大家分享下,本人遇到的,這個(gè)Store寫(xiě)出來(lái)之后 是不會(huì)起到作用的,感興趣的朋友可以看下詳細(xì)的原因及解決方法2013-04-04Ext4.2的Ext.grid.plugin.RowExpander無(wú)法觸發(fā)事件解決辦法
這篇文章主要介紹了Ext4.2的Ext.grid.plugin.RowExpander無(wú)法觸發(fā)事件解決辦法,本文中的事件指collapsebody和expandbody事件,需要的朋友可以參考下2014-08-08學(xué)習(xí)ExtJS(二) Button常用方法
ExtJS Button常用方法,需要學(xué)習(xí)的朋友可以參考下。2009-10-10ExtJS 學(xué)習(xí)專(zhuān)題(一) 如何應(yīng)用ExtJS(附實(shí)例)
相信大家已經(jīng)領(lǐng)略了ExtJs的魅力,那么要如何應(yīng)用ExtJS呢?2010-03-03ExtJS4 Grid改變單元格背景顏色及Column render學(xué)習(xí)
利用的是Column的render實(shí)現(xiàn)單元格背景顏色改變,本文給予了實(shí)現(xiàn)代碼,感興趣的朋友可以了解下,或許對(duì)你學(xué)習(xí)ExtJS4 Grid有所幫助2013-02-02ext前臺(tái)接收action傳過(guò)來(lái)的json數(shù)據(jù)示例
這篇文章以示例的方式為大家介紹了ext前臺(tái)接收action傳過(guò)來(lái)的json數(shù)據(jù),需要的朋友可以參考下2014-06-06extjs表格文本啟用選擇復(fù)制功能具體實(shí)現(xiàn)
extjs提供了方便的表格組件grid供使用,但是默認(rèn)情況下表格中的文本是不能被選中的,自然也是無(wú)法復(fù)制的,下面就為大家介紹下選擇復(fù)制功能如何啟用,感興趣的朋友可以了解下2013-10-10ExtJs3.0中Store添加 baseParams 的Bug
今天發(fā)現(xiàn)了一個(gè)ExtJS3.0中的Bug 以前用2.0的時(shí)候,喜歡這樣增加參數(shù)2010-03-03學(xué)習(xí)ExtJS(一) 之基礎(chǔ)前提
學(xué)習(xí)ExtJS前提條件,大家要想學(xué)習(xí),需要一些基礎(chǔ)知識(shí)。2009-10-10