I'm looking to do a similar thing. Right now I have a component that my dataitem refers to:
Code:
// Use the dataMap to properly set the content
dataMap : {
getSplaem : {
setIcon : 'image',
setName : 'name',
setIosTotalDownloads : 'iOSTotalDownloads',
setAndroidTotalDownloads : 'AndroidTotalDownloads',
setIosRetention : 'iOSSticky',
setAndroidRetention : 'AndroidSticky',
setTotalDownloads : 'TotalDownloads',
setGeneralInfo : {name:'name', icon:'image'},
setChart : 'name'
}
},
splaem : {
xtype : "splaem"
}
Notice the setGeneralInfo call. All of these set functions set one item in my component, but I would rather set it all at once.
I've actually had to create a temporary map inside the component that each setter would modify.
splaem:
Code:
config : {
name : null,
layout : "hbox",
items : [
{
xtype : "container",
layout : "vbox",
align : "center",
pack : "center",
items : [
{
xtype : "image",
itemId : "icon",
cls : "icon",
html : "<img src='./resources/images/ButtonMask.png'/>",
height : 175
},
{
xtype : "container",
itemId : "details",
cls : "appDetails",
tpl : [
"<table><tr><td>",
"<table width='100%'><tr><th colspan='2'>Total Downloads</th></tr>",
"<tr><td>iOS</td><td class='total'>{iOSTotalDownloads}</td></tr>",
"<tr><td>Android</td><td class='total'>{AndroidTotalDownloads}</td></tr>",
"<tr><td>Total</td><td class='total'>{TotalDownloads}</td></tr>",
"</table>",
"<table width='100%'><tr><th colspan='2'>Retention</th></tr>",
"<tr><td>iOS</td><td class='total'>{iOSSticky}</td></tr>",
"<tr><td>Android</td><td class='total'>{AndroidSticky}</td></tr>",
"</table>",
"</td></tr></table>"
]
}
]
},
Notice here that my template has several (almost all) of the bits of data I need and am getting from the dataitem.
Here's what the scary portion that I'm not proud of:
Code:
setIosTotalDownloads : function (iOSTotalDownloads) {
var thisItem = Ext.ComponentQuery.query('splaem');
thisItem = thisItem[thisItem.length - 1].down("#details");
this.tempData.iOSTotalDownloads = iOSTotalDownloads;
thisItem.setData(this.tempData);
},
setAndroidTotalDownloads : function (AndroidTotalDownloads) {
var thisItem = Ext.ComponentQuery.query('splaem');
thisItem = thisItem[thisItem.length - 1].down("#details");
this.tempData.AndroidTotalDownloads = AndroidTotalDownloads;
thisItem.setData(this.tempData);
},
setIosRetention : function (iOSRetention) {
var thisItem = Ext.ComponentQuery.query('splaem');
thisItem = thisItem[thisItem.length - 1].down("#details");
this.tempData.iOSSticky = iOSRetention;
thisItem.setData(this.tempData);
},
So what's happening here. Every time I run the set function, it has to find which item I'm currently in. The "thisItem.length - 1" gets the most current row. It then needs to find the #details component and set it's data. But the data gets wiped out each time, so I needed to set up a "tempData" map that each setter adds to. Then at the end of EACH SETTER the setData function is called.
Man it stings just typing this out. How does one set the data for this type of situation?
This is actually broken for me now since I need to now set the data for a chart that's within each of these data rows. Charts do not like using componentQueries, in fact I'm stuck until I can find the correct way to do this.