私はここにある子猫の例に従おうとしてい ます http://www.sencha.com/blog/dive-into-dataview-with-sencha-touch-2-beta-2#comment_form
データのプロパティの 1 つがオブジェクトのリストである複雑なコンポーネントがあります。setItems メソッドを使用して、リスト オブジェクトを Ext.Container にマッピングしています。しかし、うまくいかないようです。アラート ポイントで、オブジェクトが未定義として取得されます。しかし、setItems を setText に変更すると、オブジェクトの文字列表現が得られます。私が欠けているものについて何か提案はありますか?
Ext.define('MyListItem', {
extend: 'Ext.dataview.component.DataItem',
requires: ['Ext.Container'],
xtype: 'mylistitem',
config: {
sponsor: true,
dataMap: {
getSponsor: {
setItems: 'sponsor'
}
}
},
applySponsor: function(config) {
// I put an alert here to see if I get getSponsor() but the object I get here is undefined
alert(this.getSponsor());
return Ext.factory(config, Ext.Container, this.getSponsor());
},
updateSponsor: function(newNameButton, oldNameButton) {
if (oldNameButton) {
this.remove(oldNameButton);
}
if (newNameButton) {
this.add(newNameButton);
}
},
onSponsorTap: function(button, e) {
var sponsors = record.get('sponsor');
//my specific action
}
});
Ext.define('MyApp.model.Sponsors', {
extend: 'Ext.data.Model',
xtype:'Sponsors_m',
config: {
fields: [
{name: 'level', type: 'auto'},
{name: 'id', type: 'int'},
{name: 'sponsor', type: 'Sponsor'}
]
}
});
Ext.define('MyApp.model.Sponsor', {
extend: 'Ext.data.Model',
xtype:'Sponsor_m',
config: {
fields: [
{name: 'name', type: 'auto'},
{name: 'image', type: 'auto'},
{name: 'url', type: 'auto'},
{name: 'description', type: 'auto'}
]
}
});