Oops, clicked post, not preview.
I want to read in some XML containing weather data broken up by year and month.
Code:
<years>
<year year="1995">
<month month="1">
<rain>4.69</rain>
<temp>33.6</temp>
</month>
<month month="2">
<rain>2.28</rain>
<temp>26.8</temp>
</month>
<month month="3">
<rain>NA</rain>
<temp>NA</temp>
</month>
</year>
</years>
I have this:
Code:
Ext.regModel( 'Year', {
fields: [{
name: 'year',
mapping: '@year',
type: 'int'
}],
associations: [{
type: 'hasMany',
model: 'Month',
name: 'month'
}],
proxy: {
type: 'ajax',
url: 'year.xml',
reader: {
type: 'xml',
record: 'year',
root: 'years',
idProperty: '@year'
}
}
});
Ext.regModel( 'Month', {
fields: [{
name: 'month',
mapping: '@month',
type: 'int'
},{
name: 'rain',
mapping: 'rain',
type: 'float'
},{
name: 'temp',
mapping: 'temp',
type: 'float'
}]
});
yearStore = Ext.create( 'Ext.data.Store', {
model: 'Year',
autoLoad: true
});
It reads in the years properly, but it doesn't read in the months, rain and temp data. I thought that given a hasMany association, it would know to look deeper. This seems to be what the examples show, but is not how it actually works.