我直接上代码了
Ext.onReady(function(){
//定义列模型
var cm = new Ext.grid.ColumnModel([
{header:'编号',width:50,dataIndex:'Id'},
{header:'姓名',width:80,dataIndex:'Name',tooltip:'这是你的姓名'},
{header:'性别',width:40,dataIndex:'Sex',align:'center'},
{header:'学历',width:80,dataIndex:'Education',align:'center'},
{id:'memo',header:'备注',dataIndex:'Memo'}
]);
//proxy
var proxy = new Ext.data.HttpProxy({url:"servlet/PageServlet",method:'post'});
//record
var human = Ext.data.Record.create([
{name:'Id',type:'string',mapping:'hid'},
{name:'Name',type:'string',mapping:'name'},
{name:'Sex',type:'string',mapping:'sex'},
{name:'Education',type:'string',mapping:'edu'},
{name:'Memo',type:'string',mapping:'memo'}
]);
//reader
var reader = new Ext.data.JsonReader({totalProperty:'totalProperty',root:'root'},human);
//store
var store = new Ext.data.Store({
proxy:proxy,
reader:reader
});
store.load({params:{start:0,limit:6}});
var grid = new Ext.grid.GridPanel({
title:'中国公民',
width:600,
collapsible:true,
autoHeight:true,
cm:cm,
store: store,
renderTo:'mydiv',
autoExpandColumn:'memo',
buttonAlign:'center',
loadMask: {msg:'正在加载数据,请稍侯……'},
bbar:new Ext.PagingToolbar({
store:store,
pageSize:6,
displayInfo:true,
buttons:[
{text:'隐藏摘要'},
{text:'菜单',menu:new Ext.menu.Menu({items:[{text:'菜单项一'},{text:'菜单项二'}]})}
]
})
});
});
<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
%>
<html>
<head>
<title>ext-02</title>
<link rel="stylesheet" type="text/css" href="css/css/ext-all.css"/>
<!-- <link rel="stylesheet" type="text/css" href="css/css/xtheme-access.css"/>
-->
<link rel="stylesheet" type="text/css" href="css/lala.css"/>
<script type="text/javascript" src="js/ext-base.js"></script>
<script type="text/javascript" src="js/ext-all.js"></script>
<script type="text/javascript" src="js/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/grid.js"></script>
</head>
<body>
<div id="mydiv"></div>
</body>
</html>