[code="html"]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
sampledata-sheldon.xml
[code="xml"]
<?xml version="1.0" encoding="gb2312"?>
0446613657
http://www.amazon[*SNIP*]JVQEG2
Sidney Sheldon
Warner Books
Book
Are You Afraid of the Dark?
[/code]
只显示了以行表头而已,其他没显示了,请问怎么才能显示出xml中的数据呀
这有个使用xml作为数据源的例子,很详细,也是grid的,你看看就明白了!
[url]http://java2000-net.iteye.com/blog/241968[/url]
record:'Item', 改为
record:'ItemAttributes',
然后grid加个高度
record是表示放在grid的数据 你的数据
Sidney Sheldon
Warner Books
Book
Are You Afraid of the Dark?
这个标签 ItemAttributes 和你record:'Item', 这个对应不上 所以数据无法显示
我调试了你的代码 我这里都出来了
我就把 record:'Item', 改为
record:'ItemAttributes', 然后grid加 height:500 高度太...
然后就好使了 莫非你的url路径 和那个xml所放的位置的路径 不一致??
看这一点
[code="js"]
[/code]
你应该把你的 record:'Item', 设置成 record:'ItemAttributes', 因为你那些字段都在这个节点下面。我那个例子已经很明确了!仔细看下
总之你的代码 我就改了我说的那个 其余任何没动
还有你的id id:'ASIN' 这个‘ASIN’不属于ItemAttributes节点下的元素啊。你的xml再整理一下!
再改成
[code="js"]
var ItemAttributes= Ext.data.Record.create([
{name: 'Author'},
{name: 'Manufacturer'},
{name: 'ProductGroup'},
{name: 'Title'},
]);
var dataStore = new Ext.data.Store({
proxy:new Ext.data.HttpProxy({url:'sampledata-sheldon.xml'}),
reader:new Ext.data.XmlReader({
record:'ItemAttributes'
//id:'ASIN'
},ItemAttributes)
});
dataStore.load();
[/code]
这样试试!
。。。郁闷,是不是压根没请求到你的xml啊?地址对吗?
你使用ext哪个版本?我看3的HttpProxy的构造函数变了,没有url配置项了
HttpProxy( Object conn, Object conn ) 。
你干脆换成
[code="js"]
[/code]
这样。不用代理了!