Ext中的分页问题
时间:2010-11-03
来源:互联网
Ext.onReady(function(){
var cm=new Ext.grid.ColumnModel([
{header:'用户编号',width: 60,sortable:true,resizable:false,dataIndex:'userid'},
{header:'用户名',width: 100,sortable:true,resizable:false,dataIndex:'username'},
{header:'邮箱',width: 150,sortable:true,resizable:false,dataIndex:'email'},
{header:'用户年龄',width: 60,sortable:true,resizable:false,dataIndex:'userage'},
{header:'用户生日',width: 100,sortable:true,resizable:false,dataIndex:'birthday'},
{header:'用户余额',width: 60,sortable:true,resizable:false,dataIndex:'money'}
]);
var proxys= new Ext.data.HttpProxy({url: "fenyeshuju.jsp"});
/*var users = Ext.data.Record.create([
{name: "userid", type: "int"},
{name: "username", type: "string"},
{name: "email", type: "string"},
{name: "userage", type: "string"},
{name: "birthday", type: "date"},
{name: "money", type: "double"}
]);*/
var readers = new Ext.data.JsonReader({
totalProperty : "totalProperty",
root : "root"
}, [
{name: 'userid'},
{name: 'username'},
{name: 'email'},
{name: 'userage'},
{name: 'birthday'},
{name: 'money'}
]);
var store = new Ext.data.Store({
proxy : proxys,
reader : readers
});
store.load({params: {start: 0, limit: 5}});
var grid = new Ext.grid.GridPanel({
title:"用户信息展示",
renderTo:'aa',
autoHeight : true,
loadMask:true,
colModel:cm,
store:store,
viewConfig:{forceFit:true},
bbar:new Ext.PagingToolbar({
pageSize:5,
store:store,
displayInfo:true,
displayMsg:'显示第{0}条到{1}条记录,一共{2}条',
emptyMsg:"没有记录"
})
});
});
jsp页面:
<%
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
int start=Integer.parseInt(request.getParameter("start")) ;
int limit=Integer.parseInt(request.getParameter("limit")) ;
int end =start+limit;
UserBiz userBiz=new UserBiz();
int totalProperty=userBiz.getAll().size();
if(end>totalProperty){
end=totalProperty;
}
List<Users>list= userBiz.page(start,limit);
try{
String json="{totalProperty:"+totalProperty+",root:[";
for(int i=0;i<list.size();i++){
json+="{userid:"+list.get(i).getUserid()+",username:'"+list.get(i).getUsername()
+"',email:'"+list.get(i).getEmail()+"',userage:"+list.get(i).getUserage()+",birthday:'"+
list.get(i).getBirthday()+"',money:"+list.get(i).getMoney()+"}";
if(i!=list.size()-1){
json+=",";
}
}
json+="])";
System.out.println(json);
response.getWriter().write(json);
}catch(Exception e) {
e.printStackTrace();
}
%>
后台可以打印出JSON格式的数据 :
{totalProperty:22,root:[
{userid:1,username:'xiaoxin',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0},
{userid:2,username:'xsn',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0},
{userid:3,username:'xs22n',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0},
{userid:4,username:'xs2wn',email:'[email protected]',userage:19,birthday:'1991-08-10 00:00:00.0',money:50.0},
{userid:5,username:'xsfn',email:'[email protected]',userage:19,birthday:'1991-01-10 00:00:00.0',money:50.0}
]
)}
到展示页面也可以看到Grid控件 就是里面不出数据
求解!!!
var cm=new Ext.grid.ColumnModel([
{header:'用户编号',width: 60,sortable:true,resizable:false,dataIndex:'userid'},
{header:'用户名',width: 100,sortable:true,resizable:false,dataIndex:'username'},
{header:'邮箱',width: 150,sortable:true,resizable:false,dataIndex:'email'},
{header:'用户年龄',width: 60,sortable:true,resizable:false,dataIndex:'userage'},
{header:'用户生日',width: 100,sortable:true,resizable:false,dataIndex:'birthday'},
{header:'用户余额',width: 60,sortable:true,resizable:false,dataIndex:'money'}
]);
var proxys= new Ext.data.HttpProxy({url: "fenyeshuju.jsp"});
/*var users = Ext.data.Record.create([
{name: "userid", type: "int"},
{name: "username", type: "string"},
{name: "email", type: "string"},
{name: "userage", type: "string"},
{name: "birthday", type: "date"},
{name: "money", type: "double"}
]);*/
var readers = new Ext.data.JsonReader({
totalProperty : "totalProperty",
root : "root"
}, [
{name: 'userid'},
{name: 'username'},
{name: 'email'},
{name: 'userage'},
{name: 'birthday'},
{name: 'money'}
]);
var store = new Ext.data.Store({
proxy : proxys,
reader : readers
});
store.load({params: {start: 0, limit: 5}});
var grid = new Ext.grid.GridPanel({
title:"用户信息展示",
renderTo:'aa',
autoHeight : true,
loadMask:true,
colModel:cm,
store:store,
viewConfig:{forceFit:true},
bbar:new Ext.PagingToolbar({
pageSize:5,
store:store,
displayInfo:true,
displayMsg:'显示第{0}条到{1}条记录,一共{2}条',
emptyMsg:"没有记录"
})
});
});
jsp页面:
<%
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
int start=Integer.parseInt(request.getParameter("start")) ;
int limit=Integer.parseInt(request.getParameter("limit")) ;
int end =start+limit;
UserBiz userBiz=new UserBiz();
int totalProperty=userBiz.getAll().size();
if(end>totalProperty){
end=totalProperty;
}
List<Users>list= userBiz.page(start,limit);
try{
String json="{totalProperty:"+totalProperty+",root:[";
for(int i=0;i<list.size();i++){
json+="{userid:"+list.get(i).getUserid()+",username:'"+list.get(i).getUsername()
+"',email:'"+list.get(i).getEmail()+"',userage:"+list.get(i).getUserage()+",birthday:'"+
list.get(i).getBirthday()+"',money:"+list.get(i).getMoney()+"}";
if(i!=list.size()-1){
json+=",";
}
}
json+="])";
System.out.println(json);
response.getWriter().write(json);
}catch(Exception e) {
e.printStackTrace();
}
%>
后台可以打印出JSON格式的数据 :
{totalProperty:22,root:[
{userid:1,username:'xiaoxin',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0},
{userid:2,username:'xsn',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0},
{userid:3,username:'xs22n',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0},
{userid:4,username:'xs2wn',email:'[email protected]',userage:19,birthday:'1991-08-10 00:00:00.0',money:50.0},
{userid:5,username:'xsfn',email:'[email protected]',userage:19,birthday:'1991-01-10 00:00:00.0',money:50.0}
]
)}
到展示页面也可以看到Grid控件 就是里面不出数据
求解!!!
作者: ct460864589 发布时间: 2010-11-03
JScript code
{totalProperty:22,root:[ {userid:'1',username:'xiaoxin',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'}, {userid:'2',username:'xsn',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'}, {userid:'3',username:'xs22n',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'}, {userid:'4',username:'xs2wn',email:'[email protected]',userage:'19',birthday:'1991-08-10 00:00:00.0',money:'50.0'}, {userid:'5',username:'xsfn',email:'[email protected]',userage:'19',birthday:'1991-01-10 00:00:00.0',money:'50.0'} ] )}
作者: leehuat 发布时间: 2010-11-04
json userid:1,username:'xiaoxin',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0},
这里面返回全部是字符串试试!
这里面返回全部是字符串试试!
作者: leehuat 发布时间: 2010-11-04
{totalProperty:22,root:[
{userid:'1',username:'xiaoxin',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'},
{userid:'2',username:'xsn',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'},
{userid:'3',username:'xs22n',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'},
{userid:'4',username:'xs2wn',email:'[email protected]',userage:'19',birthday:'1991-08-10 00:00:00.0',money:'50.0'},
{userid:'5',username:'xsfn',email:'[email protected]',userage:'19',birthday:'1991-01-10 00:00:00.0',money:'50.0'}
]
)}
最后是不是多了一个)这个符号。
{userid:'1',username:'xiaoxin',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'},
{userid:'2',username:'xsn',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'},
{userid:'3',username:'xs22n',email:'[email protected]',userage:'20',birthday:'1990-08-10 00:00:00.0',money:'50.0'},
{userid:'4',username:'xs2wn',email:'[email protected]',userage:'19',birthday:'1991-08-10 00:00:00.0',money:'50.0'},
{userid:'5',username:'xsfn',email:'[email protected]',userage:'19',birthday:'1991-01-10 00:00:00.0',money:'50.0'}
]
)}
最后是不是多了一个)这个符号。
作者: licip 发布时间: 2010-11-04
JScript code
{totalProperty:22,root:[ {userid:1,username:'xiaoxin',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0}, {userid:2,username:'xsn',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0}, {userid:3,username:'xs22n',email:'[email protected]',userage:20,birthday:'1990-08-10 00:00:00.0',money:50.0}, {userid:4,username:'xs2wn',email:'[email protected]',userage:19,birthday:'1991-08-10 00:00:00.0',money:50.0}, {userid:5,username:'xsfn',email:'[email protected]',userage:19,birthday:'1991-01-10 00:00:00.0',money:50.0} ] )}//多了)号,不要就可以了
作者: IBM_hoojo 发布时间: 2010-11-04
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28