PDA

View Full Version : Usage of member functions in an itemTpl



parky128
21 Oct 2013, 5:38 AM
Hi,

I would like to be able to access application level variables from with a member function of an itemTpl I have configured in a list component. Here is my itemTpl definition (taken from Architect generated code)


itemTpl: Ext.create('Ext.XTemplate',
'<div><div style="display:inline-block;"> <img border = "0" height="20px" width="20px" style="margin-right:5px;" src="{[values.IsSelected == true ? "resources/images/checkbox_checked_icon.png": "resources/images/checkbox_unchecked_icon.png"]}" /><div class="{[values.InJourney == true ? "vehicleInJourney": "vehicleOutJourney"]}" style="display:inline-block; vertical-align:top;">{UnitName}</div></div><div style="display:inline-block; float:right;"><tpl if="this.nameCheck(UnitName)"><span class="Icon16 battery11" style="display:inline-block; vertical-align:top;"></span><span class="journeyLastReportedTimestamp">Unknown</span></tpl></div></div>',
'<div class="journeyCurrentLocation">{Location}</div>',
'<div style="padding-top:2px;"><div style="display:inline-block;"><span class="Icon16 Urr{UrrID}" style="display:inline-block; vertical-align:top;"></span><span class="journeyLastReportedTimestamp">{EventDTDisplay}</span></div>',
{
nameCheck: function(name) {
if( name == 'something'){
//To Do: Access this.application or similar for retrieving global variables
console.log('something found!');
}
}
}
)

Is it possible to change the scope as part of the function configuration so I can call say 'this.getApplication()' where all my globals are currently defined and set?

tt88
21 Oct 2013, 6:16 AM
Use [appname].app....
For example to get the controller:
MyApplicationsName.app.getController('ControllersName');
Then you don't need to use 'this'