babar.sajjad
25 Jan 2011, 9:08 AM
Hi,
I have two tables User and Meal. And these models are associated with each other :
Ext.regModel('User', {
fields:[ 'id','uuid', ‘name’ ],
associations: [
{type: 'hasMany', model: 'Meal', name: 'Meal', associationKey: 'Meal'}
]
});
Ext.regModel('Meal', {
fields:[
'id','name'
]
});
I m loading these Models in store like this:
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 response is in XML format 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 loads User data instead of loading both User and Meal data. I follow the documentation but did not get required results. Any help is appreciated. Thanks in advance.
I have two tables User and Meal. And these models are associated with each other :
Ext.regModel('User', {
fields:[ 'id','uuid', ‘name’ ],
associations: [
{type: 'hasMany', model: 'Meal', name: 'Meal', associationKey: 'Meal'}
]
});
Ext.regModel('Meal', {
fields:[
'id','name'
]
});
I m loading these Models in store like this:
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 response is in XML format 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 loads User data instead of loading both User and Meal data. I follow the documentation but did not get required results. Any help is appreciated. Thanks in advance.