ここに示すように、親ストアと子ストアがあります。
親モデル
Ext.define('APP.model.Client', {
extend: 'Ext.data.Model',
requires: [
'APP.model.Website', 'Ext.data.association.HasMany', 'Ext.data.association.BelongsTo'],
fields: [{
name: 'id',
type: 'string'
}, {
name: 'name',
type: 'string'
}, {
name: 'slug',
type: 'string'
}, {
name: 'active',
type: 'boolean'
}, {
name: 'current',
type: 'boolean'
}],
hasMany: {
model: 'APP.model.Website',
name: 'websites'
}
});
子モデル
Ext.define('APP.model.Website', {
extend: 'Ext.data.Model',
fields: [{
name: 'id',
type: 'string'
}, {
name: 'client_id',
type: 'string'
}, {
name: 'sub_domain',
type: 'string'
}, {
name: 'active',
type: 'boolean'
}],
belongsTo: 'APP.model.Client'
});
サーバー経由で AJAX 呼び出しを使用して、Clients
ストアをロードしていますが、正常にロードされています。しかし、ストアにはデータが取り込まれていません。ストアの on.load 関数Websites
にブレークポイントを設定して、何が取り込まれているかを確認すると、ストアにはクライアント データのみが取り込まれますが、そのストアのプロパティでは、すべてのデータを確認できます。データ。正しく返されていますが、extjs が正しくありません。店舗は次のとおりです。Clients
Client
raw
websites
クライアントストア
Ext.define('APP.store.Clients', {
extend: 'Ext.data.Store',
autoLoad: false,
model: 'APP.model.Client',
proxy: {
type: 'ajax',
url: '/client/list',
reader: {
type: 'json',
root: 'items'
}
},
sorters: [{
property: 'name',
direction: 'ASC'
}]
});
ウェブサイト ストア
Ext.define('APP.store.Websites', {
extend: 'Ext.data.Store',
requires: ['Ext.ux.Msg'],
autoLoad: false,
model: 'APP.model.Website',
proxy: {
type: 'ajax',
url: '/client/list',
reader: {
type: 'json',
root: 'items'
},
writer: {
type: 'json'
}
},
sorters: [{
property: 'sub_domain',
direction: 'ASC'
}]
});
私の最終的な結果は...要素をクリックできるように両方のストアにデータを入力したいのですが、親ストアから何かをロードすると、子ストアにアクセスできます(見つけたらもっとあります)この問題) タブにいくつかのグリッドを設定します。
セットアップに関して何が欠けていますか? 数日前に extjs4 をダウンロードしたばかりなので、4.1 を使用しています。