DontTakeEmOff316
15 Jun 2011, 1:30 PM
Hi, I'm having trouble configuring my models and readers to read some more complex XML.
The XML looks like...
<ItemCollection>
<Item>
<ID>2</ID>
<Version>1</Version>
<Product>Product1</Product>
<ChildCollection>
<ChildItem>
<ID>3</ID>
</ChildItem>
<ChildCollection>
</Item>
<ItemCollection>
My models are...
Ext.define('ChildModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
]
});
Ext.define('ItemModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
{ name: 'Version', type: 'string' }
],
hasMany: { name: 'ChildItem', model: 'ChildModel' }
});
with a reader setup like...
var childReader = new Ext.data.XmlReader({
type: 'xml',
record: 'ChildIteml'
});
var store = new Ext.data.Store({
model: 'ItemModel',
proxy: {
url: someurl
reader: {
type: 'xml',
record: 'Item',
fields: [{
name: 'ChildCollection',
convert: function(v, n) {
return childReader.readRecords(n).records;
}
}]
}
}
});
I tried setting it up as a double reader (as per the code above) but I can not get it to work. Basically an Item can have multiple ChildItems, and all this needs to be read from the xml.
Any suggestions? Thanks a bunch.
The XML looks like...
<ItemCollection>
<Item>
<ID>2</ID>
<Version>1</Version>
<Product>Product1</Product>
<ChildCollection>
<ChildItem>
<ID>3</ID>
</ChildItem>
<ChildCollection>
</Item>
<ItemCollection>
My models are...
Ext.define('ChildModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
]
});
Ext.define('ItemModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'ID', type: 'string' },
{ name: 'Version', type: 'string' }
],
hasMany: { name: 'ChildItem', model: 'ChildModel' }
});
with a reader setup like...
var childReader = new Ext.data.XmlReader({
type: 'xml',
record: 'ChildIteml'
});
var store = new Ext.data.Store({
model: 'ItemModel',
proxy: {
url: someurl
reader: {
type: 'xml',
record: 'Item',
fields: [{
name: 'ChildCollection',
convert: function(v, n) {
return childReader.readRecords(n).records;
}
}]
}
}
});
I tried setting it up as a double reader (as per the code above) but I can not get it to work. Basically an Item can have multiple ChildItems, and all this needs to be read from the xml.
Any suggestions? Thanks a bunch.