sencha dataitem datamap setItems
- by user1795667
I'm trying to follow the kitten example given here
http://www.sencha.com/blog/dive-into-dataview-with-sencha-touch-2-beta-2#comment_form
and I have complex components in which one of the property of my data is a list of objects. And I do find a method for setting a list of objects which is setItems however it does not seem to work. My object array is my model MyApp.Model.Sponsor. Could anyone suggest what I'm missing to get this working?
Ext.define('MyListItem', {
extend: 'Ext.dataview.component.DataItem',
requires: ['Ext.Button','Ext.Img',
'MyApp.model.Sponsors',
'MyApp.model.Sponsor'],
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, MyApp.model.Sponsor, 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'}
]
}
});