busybee
18 Oct 2010, 1:05 PM
Hello I am trying to populate xml data into a list. But can't get any data to be populated. Can somebody tell me where I am going wrong.
Ext.onReady(function(){
Ext.regModel('State', {
fields: [
{name: 'Id', mapping: '@Id'},
{name:"Name", mapping: "@Name"},
{name:"email", mapping: "@email"},
{name:"zipcode", mapping: "@Zipcode"}
]
});
var store = new Ext.data.Store({
model: 'State',
proxy: {
type: 'ajax',
url: 'test.xml',
reader: {
type: 'xml',
root:'States'
}
},
autoLoad: true
});
var list = new Ext.List({
//floating: true,
//singleSelect: true,
store: store,
centered: true,
tpl: '<tpl for="."><div class="Car"><strong>{Name} {email}</strong></div></tpl>',
itemSelector: 'div.Car'
});
list.show();
});
XML data looks like this.
<?xml version="1.0" encoding="utf-8" ?>
<States>
<State Id="101" Name="John" email="abc@test.com" Zipcode="12345">
<City Id="501" CustomerName="Darryl" Zipcode="12345" />
<City Id="502" CustomerName="Kai" Zipcode="12345" />
</State>
<State Id="102" Name="John" email="abc@test.com" Zipcode="67890" >
<City Id="501" CustomerName="Darryl" Zipcode="67890" />
<City Id="502" CustomerName="Kai" Zipcode="67890" />
</State>
</States>
Thanks
Ext.onReady(function(){
Ext.regModel('State', {
fields: [
{name: 'Id', mapping: '@Id'},
{name:"Name", mapping: "@Name"},
{name:"email", mapping: "@email"},
{name:"zipcode", mapping: "@Zipcode"}
]
});
var store = new Ext.data.Store({
model: 'State',
proxy: {
type: 'ajax',
url: 'test.xml',
reader: {
type: 'xml',
root:'States'
}
},
autoLoad: true
});
var list = new Ext.List({
//floating: true,
//singleSelect: true,
store: store,
centered: true,
tpl: '<tpl for="."><div class="Car"><strong>{Name} {email}</strong></div></tpl>',
itemSelector: 'div.Car'
});
list.show();
});
XML data looks like this.
<?xml version="1.0" encoding="utf-8" ?>
<States>
<State Id="101" Name="John" email="abc@test.com" Zipcode="12345">
<City Id="501" CustomerName="Darryl" Zipcode="12345" />
<City Id="502" CustomerName="Kai" Zipcode="12345" />
</State>
<State Id="102" Name="John" email="abc@test.com" Zipcode="67890" >
<City Id="501" CustomerName="Darryl" Zipcode="67890" />
<City Id="502" CustomerName="Kai" Zipcode="67890" />
</State>
</States>
Thanks