问题
When I do a find('all') in cakephp with model associations, the format the data is returned in is similar to this:
{
data: [
{
'mainModel': {},
'associatedModel1': {},
'associatedModel2': {},
'associatedModel3': {},
'associatedModel4': {}
},
{
'mainModel': {},
'associatedModel1': {},
'associatedModel2': {},
'associatedModel3': {},
'associatedModel4': {}
}
]
}
when I write a store in ExtJS, I would need to set the record config option to mainModel, but then how would the associations work? As far as I can tell, extjs would expect the data to be formatted like so:
{
data: [
{
'mainModel': {
'associatedModel1': {},
'associatedModel2': {},
'associatedModel3': {},
'associatedModel4': {}
}
},
{
'mainModel': {
'associatedModel1': {},
'associatedModel2': {},
'associatedModel3': {},
'associatedModel4': {}
}
}
]
}
am I correct in understanding this? How can I get ExtJS and CakePHP to play nicely with each other? Am I forced to manipulate the data to fit to ExtJS' liking?
来源:https://stackoverflow.com/questions/10975454/getting-extjs-and-cakephp-associated-models-to-work-together