日期:2014-05-16 浏览次数:20354 次
Ext.onReady(function(){ //定义表头 var oColModels = new Ext.grid.ColumnModel([ {header:'ID',dataIndex:'id'}, {header:'姓名',dataIndex:'name'}, {header:'EMail',dataIndex:'email'}, {header:'性别',dataIndex:'sex'}, {header:'年龄',dataIndex:'age'} ]); //定义数据结构,即数据库字段 var aFields = ["id","name","email","sex","age"]; //数据集 var aDatas = [ ["1","name1","name1@abc.com","1","21"], ["2","name2","name2@abc.com","0","22"], ["3","name3","name3@abc.com","1","23"], ["4","name4","name4@abc.com","0","24"], ["5","name5","name5@abc.com","1","25"] ]; //数据存储器 var oStore = new Ext.data.SimpleStore({ fields : aFields, data : aDatas }); // var oGrid = new Ext.grid.GridPanel({ title:"grid列表显示示例", width:600, height:200, colModel : oColModels, store : oStore }); // oGrid.render(Ext.get("grid-example")); });
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="../../scripts/ext/adapter/ext/ext-base.js"></script> <script type="text/javascript" src="../../scripts/ext/ext-all-debug.js"></script> <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css"></link> <script language="javascript" src="grid.js"></script> </head> <body> <div id="grid-example"></div> </body> </html>