Ext Grid 分页 数据不显示

wo321244 2009-12-01 03:28:38
请大虾们帮忙看一下
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>HelloWord.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../resources/css/ext-all.css"/>
<script type="text/javascript" src="../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../ext-all.js"></script>
<script type="text/javascript" src="../examples/ux/BufferView.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var cm=new Ext.grid.ColumnModel([
{header:"编号",dataIndex:"id"},
{header:"名称",dataIndex:"name"},
{header:"描述",dataIndex:"descn"}
]);
var store=new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'Data.jsp'}),
reader:new Ext.data.JsonReader({
totalProperty:'totalProperty',
root:'root',
fields:[
{name:'id'},
{name:'name'},
{name:'descn'}
]
})
});
store.load({params:{start:0,limit:10}});
var grid=new Ext.grid.GridPanel({
el:'grid',
ds:store,
cm:cm,
autoHeight:true,
viewConfig:{
forceFit:true
},
bbar:new Ext.PagingToolbar({
store:store,
pageSize:10,
displayInfo:true,
displayMsg:'显示第 {0} 条到{1} 条记录,一共{2}条',
emptyMsg:'没有记录'
})
}); grid.render();
});

</script>
</head>

<body>

<div id="grid" style="height:265px;"></div>
</body>
</html>



jsp代码是
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'Data.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<%
String start=request.getParameter("start");
String limit=request.getParameter("limit");
try{
int index=Integer.parseInt(start);
int pageSize=Integer.parseInt(limit);

String json="{totalProperty:100,root:[";
for(int i=index;i<pageSize+index;i++){
json+="{id:"+i+",name:'name"+i+"',descn:'descn"+i+"'}";
if(i!=pageSize+index-1){
json+=",";
}
}
json+="]}";
System.out.println(json);
response.getWriter().write(json);
}catch(Exception ex){
}
%>
</body>
</html>
...全文
191 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧