getting extjs and cakephp associated models to work together

为君一笑 提交于 2019-12-24 10:56:48

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!