我正在尝试遵循此处给出的小猫示例 http://www.sencha.com/blog/dive-into-dataview-with-sencha-touch-2-beta-2#comment_form
我有复杂的组件,其中我的数据属性之一是对象列表。我正在使用 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'}
]
}
});