-
4 Nov 2012 6:43 PM #1
Unanswered: New to Sencha and having a hard time with DataItem with custom container
Unanswered: New to Sencha and having a hard time with DataItem with custom container
I'm trying to follow this thread http://www.sencha.com/forum/showthread.php?196320
and created my own container for the component in the DataItem definition. I have declared
useComponents: true, defaultType: 'mylistitem' in my DataView
Ext.define('AgileApp.view.MyListItem', {
extend: 'Ext.dataview.component.DataItem',
requires: ['Ext.Button', 'AgileApp.view.SponsorList','Ext.Img',
'AgileApp.model.Sponsors',
'AgileApp.model.Sponsor'],
xtype: 'mylistitem',
config: {
level:true,
sponsor: true,
dataMap: {
getLevel: {
setText: 'level'
},
getSponsor: {
setSponsor: 'sponsor'
}
},
layout: {
type: 'vbox',
align: 'center'
},
sponsor: {
xtype:'sponsorView',
}
},
applyLevel: function(config) {
// alert(this.getLevel());
return Ext.factory(config, Ext.Button, this.getLevel());
},
applySponsor: function(config) {
// alert(this.getSponsor());
return Ext.factory(config, AgileApp.view.SponsorList, this.getSponsor());
},
updateLevel: function(newNameButton, oldNameButton) {
if (oldNameButton) {
this.remove(oldNameButton);
}
if (newNameButton) {
this.add(newNameButton);
}
},
updateSponsor: function(newNameButton, oldNameButton) {
var sponsor = Ext.getStore('Sponsor');
if (oldNameButton) {
sponsor.remove(oldNameButton);
}
if (newNameButton) {
sponsor.add(newNameButton);
}
},
});
My component definition is like this:
Ext.define('AgileApp.view.SponsorList', {
extend: 'Ext.Container',
xtype: 'sponsorView',
config: {
items: [
{
xtype: 'Sponsor_m', id:'sponsor'
}
],
html:'test',
// itemTpl: [
// '<tpl for=".">test{name}-------{description}</tpl>'
// ]
},
setSponsor:function(store){
alert("got into store" + store);
}
});
But this is not displaying the sponsor list as expected and instead I get an error on the console:
Uncaught TypeError: Object [object Object] has no method 'getItemId'
i'm not able to understand what i'm doing wrong here. Any help on how to reference this custom component and display the data on that would be highly appreciated.
Thanks
-
6 Nov 2012 3:06 AM #2
Your post really hard to read.
sponsor is a store,oldNameButton and newNameButton are component.Code:updateSponsor: function(newNameButton, oldNameButton) { var sponsor = Ext.getStore('Sponsor'); if (oldNameButton) { sponsor.remove(oldNameButton); } if (newNameButton) { sponsor.add(newNameButton); } }
store.remove(component)?
also remove the id config,your have many 'sponsorView' instance .
Code:{ xtype: 'Sponsor_m' //, id:'sponsor' }I write English by translator.


Reply With Quote