Javascript Sencha Touch商店协会不匹配?

Javascript Sencha Touch商店协会不匹配?,javascript,extjs,sencha-touch,Javascript,Extjs,Sencha Touch,我有两个模型Category->Object和关联 Category |--Has many--->Objects 以下是分类模型: 下面是ObjectsModel: 这个协会对吗?否则,也许我不需要在两边都设置它? 我收到警告:[WARN][Ext.data.Operationprocess]无法匹配从服务器返回的更新记录 PS:我需要这些模型将与关联的存储放在一个嵌套列表中。我终于找到了一个解决方案 这是一个非常好的例子,使用了各种关联 我终于明白了这个概念 我们需要在模型中

我有两个模型Category->Object和关联

Category
    |--Has many--->Objects
以下是分类模型:

下面是ObjectsModel:

这个协会对吗?否则,也许我不需要在两边都设置它? 我收到警告:[WARN][Ext.data.Operationprocess]无法匹配从服务器返回的更新记录


PS:我需要这些模型将与关联的存储放在一个嵌套列表中。

我终于找到了一个解决方案

这是一个非常好的例子,使用了各种关联

我终于明白了这个概念

我们需要在模型中设置idProperty,并使用hasMany和belongsTo关联

类别模型:

对象模型:

就这样。但它现在不适用于我的嵌套列表

Ext.define("TouchApp.model.CategoryModel", {
    extend: "Ext.data.Model",
    config: {
        fields: [
            {
                name: 'id',
                type: 'int'
            },
            {
                name: 'name',
                type: 'String'
            }
        ],
        //Aide: http://docs.sencha.com/touch/2.2.1/#!/api/Ext.data.association.Association
        associations: [
            { type: 'hasMany', model: 'ObjectsModel', primaryKey: 'id', foreignKey: 'category'}
        ]

    }
});
Ext.define("TouchApp.model.ObjectsModel", {
    extend: "Ext.data.Model",
    config: {
        fields: [
            {
                name: 'id',
                type: 'int'
            },
            {
                name: 'name',
                type: 'String'
            },
            {
                name: 'category',
                type: 'int'
            }
        ],
        //Aide: http://docs.sencha.com/touch/2.2.1/#!/api/Ext.data.association.Association
        associations: [
            { type: 'belongsTo', model: 'CategoryModel', primaryKey: 'id', foreignKey: 'category'}
        ]
    }
});
Ext.define("TouchApp.model.CategoryModel", {
    extend: "Ext.data.Model",
    config: {
        idProperty: 'id', //The idProperty representing the "PK"
        fields: [
            {
                name: 'id',
                type: 'int'
            },
            {
                name: 'name',
                type: 'String'
            }
        ],
        //Really great example: http://docs.sencha.com/touch/2.2.1/#!/api/Ext.data.association.Association
        hasMany: [{ model: 'TouchApp.model.ObjectsModel' }] //The hasMany association setting the model associated...
    }
});
Ext.define("TouchApp.model.ObjectsModel", {
    extend: "Ext.data.Model",
    config: {
        idProperty: 'id', //The idProperty representing the "PK"
        fields: [
            {
                name: 'id',
                type: 'int'
            },
            {
                name: 'name',
                type: 'String'
            },
            {
                name: 'category',
                type: 'int'
            }
        ],
        //Realy great example: http://appointsolutions.com/2012/07/using-model-associations-in-sencha-touch-2-and-ext-js-4/
        belongsTo: [{ model: 'TouchApp.model.CategoryModel', associationKey: 'category' }] //Here the belongsTo association which tell the parent Model. AssociationKey set which key is the "FK". It will be linked to the idProperty
    }
});