모델 저장소에서 다음 JSON에 액세스하려고합니다. 루트 (이름 및 주소)에 액세스하는 데 문제가 없지만 재무 (NetWorth 또는 소득)에 액세스 할 수 없습니다. 아래 JSON이 서버에서 반환되는지 확인했습니다.Sencha Touch - 1 대 1 모델 관계에 액세스
나는 이것이 매우 쉽다는 것을 알고 있지만, 내가 본 모든 예는 1 대 다수 관계에 액세스하는 방법을 보여줍니다. 내 모델은 1 대 1입니다. 개인 -> 금융. 지금은 1 대 1 관계를 설정하는 방법을 모르기 때문에 관련 설정이 없습니다. 나는 associationTo를 시도했는데, belongsTo를 시도했다. 나는 itemTPL 내부에서 Financials.NetWorth를 시도했다. 아무것도.
누군가가 내게 빛을 보여줄 수 있습니까?
는 JSON 내가 내 모델을 등록
[{ "PersonName": "John Smith", "Address": "123 main street", "Financials": [{ "NetWorth": "$500,000", "Income":"$67,000" }] }]
서버에서 돌아왔다.
Ext.regModel('Person', {
fields: [
{name: 'Name', type:'string'},
{name: 'Address', type: 'string'},
],
});
Ext.regModel('Financials',{
fields: [
{name: 'NetWorth', type:'string'},
{name: 'Income', type: 'string'},
],
});
그리고 가게
var commStore = new Ext.data.Store({
model: 'Person',
proxy: {
type: 'ajax',
url : 'Business/GetData',
reader: {
type: 'json',
}
},
autoLoad:false,
});
와 어떤 도움이 많이 주시면 감사하겠습니다
var commList = new Ext.List({
fullscreen: false,
itemTpl : '<div>{PersonName}</div><div>{Business.NetWorth}</div>',
store: commStore,
height:500,
width:"100%",
});
목록에 다시 표시를 등록했다.