PDA

View Full Version : Load Multiple Models using Store.



irfaniqbal
26 Jan 2011, 6:30 AM
Hi All,
I have two associated models User and Meal.



Ext.regModel('User', {
fields:[ 'id','uuid', ‘name’ ],
associations: [
{type: 'hasMany', model: 'Meal', name: 'Meal', associationKey: 'Meal'}
]
});
Ext.regModel('Meal', {
fields:[
'id','name'
]
});I want to load these two models using Store. Here is code for Store.


var store = new Ext.data.Store({
model: 'User',
storeId: 'UserStore',
proxy: {
type: 'ajax',
url : 'http://myurl',
reader: {
type: 'xml',
root: 'response',
record: 'User'
},
filters: [],
}
});

The XML response is:


<?xml version="1.0" encoding="utf-8"?>
<nutritions_response>
<data>
<response>
<item>
<User>
<id>1192</id>
<uuid>4d36ea13-47d0-4ecd-94dc-082832e59055</uuid>
<name>test</name>
<Meal>
<item>
<id>6353</id>
<name>Breakfast</name>
</item>
<item>
<id>6354</id>
<name>Lunch</name>
</item>
</Meal>
</User>
</item>
</response>
</data>
</nutritions_response>


and when i Load the store it only load the User data instead of both User and Meal data. Any urgent help is my pleasure. thanks in advance