Ext有很多协会商店不加载

时间:2012-04-22 19:31:24

标签: extjs

我定义了两个模型,ScoreCard和CaregoryWeight。 ScoreCard有很多CategoryWeights。

当我创建一个网格并将关联存储传递给它(scoreCard.categoryWeights())时,即使从RESTful服务返回了项目,它也不会显示任何内容。

有什么问题?请帮忙。

以下是我的代码:

Ext.define(ModelNames.CategoryWeight, {
extend : 'Ext.data.Model',
idProperty : 'id',

fields : [ {
    name : 'id',
    type : 'int'
}, {
    name : 'weight',
    type : 'float'
}, {
    name : 'category_id',
    type : 'int'
}, {
    name : 'scorecard_id',
    type : 'int'
} ],
associations : [ {
    type : 'belongsTo',
    model : ModelNames.Category,
    primaryKey : 'id',
    forgientKey : 'category_id'
}, {
    type : 'belongsTo',
    model : ModelNames.ScoreCard,
    primaryKey : 'id',
    forgientKey : 'scorecard_id'
} ]});

Ext.define(ModelNames.ScoreCard, {
extend : 'Ext.data.Model',
idProperty : 'id',

fields : [ {
    name : 'id',
    type : 'int'
}, {
    name : 'description',
    type : 'string',
    defaults : ''
}, {
    name : 'isTemplate',
    type : 'boolean',
    defaults : true
}, {
    name : 'isValid',
    type : 'boolean',
    defaults : false
} ],
associations : [ {
    type : 'hasMany',
    model : ModelNames.ScoreRecord,
    name : 'scoreRecords',
    storeConfig : {
        autoLoad : true,
        autoSync : true,
        proxy : {
            type : 'rest',
            url : '/' + CONTEXT_PATH + '/RESTFul/ScoreRecord',
            reader : {
                type : 'json',
                root : 'items'
            },
            writer : 'json'
        }
    }
}, {
    type : 'hasMany',
    model : ModelNames.CategoryWeight,
    name : 'categoryWeights',
    storeConfig : {
        autoLoad : true,
        autoSync : false,
        proxy : {
            type : 'rest',
            url : '/' + CONTEXT_PATH + '/RESTFul/CategoryWeight',
            reader : {
                type : 'json',
                root : 'items'
            },
            writer : 'json'
        }
    }
} ]});

1 个答案:

答案 0 :(得分:0)

错字:foreignKey

由于答案不允许少于两个单词,我会补充一点,除了发现拼写错误之外,我不知道你的代码是否有用,为什么或为什么不行。

相关问题