小弟求问:在练习extjs使用时 参照网上他人代码 写如下 为什么XML文件数据不能加载显示在extjs XML grid控件中 在页面只有grid显示?
源代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>这是利用Extjs加载XML在WEB页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<link rel="stylesheet" type="text/css" href="G:\\ext-2.0-rc1\\resources\\css\\ext-all.css" />
<script type="text/javascript" src="G:\\ext-2.0-rc1\\adapter\\ext\\ext-base.js"></script>
<script type="text/javascript" src="G:\\ext-2.0-rc1\\ext-all.js"></script>
</head>
<body>
<script>
Ext.onReady(function(){
var store=new Ext.data.Store({
url:'GridData.xml',
reader: new Ext.data.XmlReader({
record:'Item'
},
['ASIN','Author','Manufacturer','ProductGroup','Title'])
});
var grid=new Ext.grid.GridPanel({
store:store,
columns:[
{header:"出版号",width:120,dataIndex:'ASIN',sortable:true},
{header:"作者",width:120,dataIndex:'Author',sortable:true},
{header:"书名",width:180,dataIndex:'Title',sortable:true},
{header:"制作商",width:115,dataIndex:'Manufacturer',sortable:true},
{header:"产品组",width:100,dataIndex:'ProductGroup',sortable:true}],
renderTo:'test_xmlGrid',
width:640,
height:100 });
store.load();
});</script>
<div id="test_xmlGrid"></div>
</body>
</html>XML文件如下:
<?xml version="1.0">
<GridResponse>
<Items>
<Item>
<ASIN>0446355453</ASIN>
<Author>Jimmy.Yang</Author>
<Manufacturer>WarnerBooks</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>MasteroftheGame</Title>
</Item>
<Item>
<ASIN>0446613657</ASIN>
<Author>SidneySheldon</Author>
<Manufacturer>WarnerBooks</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>AreYouAfraidoftheDark</Title>
</Item>
<Item>
<ASIN>04466136123</ASIN>
<Author>sdgsg</Author>
<Manufacturer>djgdsg</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>sgdjhdg</Title>
</Item>
</Items>
</GridResponse>
源代码如下:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>这是利用Extjs加载XML在WEB页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<link rel="stylesheet" type="text/css" href="G:\\ext-2.0-rc1\\resources\\css\\ext-all.css" />
<script type="text/javascript" src="G:\\ext-2.0-rc1\\adapter\\ext\\ext-base.js"></script>
<script type="text/javascript" src="G:\\ext-2.0-rc1\\ext-all.js"></script>
</head>
<body>
<script>
Ext.onReady(function(){
var store=new Ext.data.Store({
url:'GridData.xml',
reader: new Ext.data.XmlReader({
record:'Item'
},
['ASIN','Author','Manufacturer','ProductGroup','Title'])
});
var grid=new Ext.grid.GridPanel({
store:store,
columns:[
{header:"出版号",width:120,dataIndex:'ASIN',sortable:true},
{header:"作者",width:120,dataIndex:'Author',sortable:true},
{header:"书名",width:180,dataIndex:'Title',sortable:true},
{header:"制作商",width:115,dataIndex:'Manufacturer',sortable:true},
{header:"产品组",width:100,dataIndex:'ProductGroup',sortable:true}],
renderTo:'test_xmlGrid',
width:640,
height:100 });
store.load();
});</script>
<div id="test_xmlGrid"></div>
</body>
</html>XML文件如下:
<?xml version="1.0">
<GridResponse>
<Items>
<Item>
<ASIN>0446355453</ASIN>
<Author>Jimmy.Yang</Author>
<Manufacturer>WarnerBooks</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>MasteroftheGame</Title>
</Item>
<Item>
<ASIN>0446613657</ASIN>
<Author>SidneySheldon</Author>
<Manufacturer>WarnerBooks</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>AreYouAfraidoftheDark</Title>
</Item>
<Item>
<ASIN>04466136123</ASIN>
<Author>sdgsg</Author>
<Manufacturer>djgdsg</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>sgdjhdg</Title>
</Item>
</Items>
</GridResponse>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货