日期:2014-05-16 浏览次数:20345 次
<html>
<head>
<link rel="stylesheet" type="text/css" href="./ExtJS4/resources/css/ext-all.css" />
<script type="text/javascript" src="./ExtJS4/ext-all.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
var columns = [
{header:'编号',dataIndex:'id'},
{header:'名称',dataIndex:'name'},
{header:'描述',dataIndex:'descn'}
];
var store = new Ext.data.Store({
proxy: {
type: 'ajax',
url: '09_02_01.jsp',
reader: {
type: 'json',
totalProperty: 'totalProperty',
root: 'root',
idProperty: 'id'
}
},
fields: [
{name: 'id'},
{name: 'name'},
{name: 'descn'}
]
});
var grid = new Ext.grid.GridPanel({
renderTo: 'grid',
autoHeight: true,
store: store,
columns: columns,
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: store,
displayInfo: true,
displayMsg: '显示第 {0} 条到 {1} 条记录,一共 {2} 条',
emptyMsg: "没有记录"
})
});
store.load({params:{start:1,limit:10}});
});
</script>
</head>
<body>
<div id="grid" style="height:265px;"></div>
</body>
</html>
<%
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 += ",";
}