日期:2014-05-16 浏览次数:20786 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css" /> <script type="text/javascript" src="extjs/adapter/ext/ext-base.js"></script> <script type="text/javascript" src="extjs/ext-all.js"></script> <script> var cm = new Ext.grid.ColumnModel([ {header:'编号',dataIndex:'id'}, {header:'姓名',dataIndex:'name'}, {header:'性别',dataIndex:'sex'}, {header:'描述',dataIndex:'descn'} ]); var data = [ ['1','张三','男','描述一'], ['2','李四','女','描述二'], ['3','王五','男','描述三'], ['4','赵六','女','描述四'], ['5','小七','男','描述五'] ]; var store = new Ext.data.Store({ proxy: new Ext.data.MemoryProxy(data), reader: new Ext.data.ArrayReader({},[ {name:'id'}, {name:'name'}, {name:'sex'}, {name:'descn'} ]) }); store.load(); Ext.onReady(function(){ var grid = new Ext.grid.GridPanel({ renderTo:'div', striptRows:true, autoHeight:true, store:store, title:'表格测试', cm:cm }); }); </script> <div id="div"></div>
------解决方案--------------------
reader 里设置一个参数 id : 'id'