0
ネストされたJSONをストアにロードしたいが、データが正しくマッピングされていない。 1つのregModelで問題はありませんが、私は関連付けを行うことができません。Sencha TouchのネストされたJSON - アソシエーション付きストアロード
// JSON in test.json
{"message" : {
"returnCodes": [
{
"value": "0",
"code": "200",
"description": "OK"
},
{
"value": "0",
"code": "200",
"description": "OK"
}
]
}}
// Model with associations
Ext.regModel("ReturnCode", {
fields : [{
name : "value",
type : "string"
}, {
name : "code",
type : "string"
}, {
name : "description",
type : "string"
}],
belongsTo: "Message"
});
Ext.regModel("Message", {
hasMany: {
model : "ReturnCode",
name : "returnCodes"
}
});
// Store
var jobStore = new Ext.data.Store({
model : 'Message',
autoLoad: true,
proxy : {
type : 'ajax',
url: 'test.json',
reader : {
type : 'json',
root : 'message.returnCodes'
}
}});
// List
var list = Ext.extend(Ext.List, {
fullscreen : true,
store : jobStore,
grouped : false,
itemTpl : '<div>{code}</div>' // no output
});
私が店に見てみると、すべてのデータは、データセクション内のストアオブジェクトが、何の生の部分に格納されます。両方のreturnCodeオブジェクトのリストでは、リスト項目が作成されますが、マッピングが成功しなかったためにデータで満たされません - > itemTplはデータを取得しません。