-1

ScoreCard と CaregoryWeight の 2 つのモデルを定義しています。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'
        }
    }
} ]});
4

1 に答える 1

0

タイプミス: 外部キー

2 語未満の回答は許可されていないため、タイプミスを見つけることは別として、コードが機能するかどうか、なぜ機能するのか、なぜ機能しないのかはわかりません。

于 2012-04-30T14:20:06.210 に答える