首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

Grid初识4

2012-11-05 
Grid初识四//user/grid-data.xml?xml version1.0 encodingutf-8?datasettotal100/totalrow

Grid初识四
//user/grid-data.xml
<?xml version="1.0" encoding="utf-8"?>
<dataset>
<total>100</total>
<row>
<id>1</id>
<name>langsin1</name>
<email>langsin@langsin.com</email>
<sex>0</sex>
<age>20</age>
</row>
<row>
<id>2</id>
<name>langsin2</name>
<email>langsin@langsin.com</email>
<sex>0</sex>
<age>21</age>
</row>
<row>
<id>3</id>
<name>langsin3</name>
<email>langsin@langsin.com</email>
<sex>0</sex>
<age>22</age>
</row>
<row>
<id>4</id>
<name>langsin4</name>
<email>langsin@langsin.com</email>
<sex>0</sex>
<age>20</age>
</row>
<row>
<id>5</id>
<name>langsin5</name>
<email>langsin@langsin.com</email>
<sex>0</sex>
<age>24</age>
</row>
</dataset>


Ext.onReady(function(){

var fields = ["id","name","email","sex","age"];

var store = new Ext.data.Store({
autoLoad:true,
//url:"user/grid-data.xml",
proxy:new Ext.data.HttpProxy({url: "user/grid-data.xml"}),
reader:new Ext.data.XmlReader({id:"id",record:"row",totalRecords:"total"},fields)
});
//store.load();

var cm = new Ext.grid.ColumnModel([{
header:"id",
dataIndex:"id"
},{
header:"email",
dataIndex:"email"
},{
header:"姓名",
dataIndex:"name"
},{
header:"性别",
dataIndex:"sex"
},{
header:"年龄",
dataIndex:"age"
}]);

var grid = new Ext.grid.GridPanel({
title:"grid列表显示示例",
width:600,
height:300,
cm:cm,
store:store
});
grid.render(Ext.getBody());
});

热点排行