sencha dataitem datamap setItems
Posted
by
user1795667
on Stack Overflow
See other posts from Stack Overflow
or by user1795667
Published on 2012-11-04T22:51:00Z
Indexed on
2012/11/04
22:59 UTC
Read the original article
Hit count: 511
sencha-touch-2
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'}
]
}
});
© Stack Overflow or respective owner