View Full Version : Question about XTemplate usage in a view config

2 Dec 2011, 8:00 AM

Is it possible to get a reference to the application instance from a member function of an XTemplate in a view config? Sorry, thats quite a mouthful there! Here is some code:

Ext.define('PinpointersTouch.view.UnitList', {
extend: 'Ext.List',
xtype: 'unitslist',
config: {
fullscreen: true,
itemTpl: new Ext.XTemplate(
'<ul id="unitList">',
'<tpl for=".">',
'<table width="100%" cellspacing="0">',
'<td style="width:30px; text-align:center">{[this.getUnitIcon(values.id)]}</td>',
'<td valign="middle"> - {UnitName}</td>',
getUnitIcon: function(untID) {
//var iconNum = this.application.getTrackingListStore().getById(untID).data.MapIcon;

//TO Do: Can I get a reference to the application instance from in here???
store: 'CurrentGrid'

I need to look up some values in another store in my application based on a value being passed into the XTemplate member function.

2 Dec 2011, 9:37 AM
Yes and no.

By default, the application instance isn't cached anymore so in your launch method you can cache it on your namespace:

name : 'MyApp',

launch : function() {
MyApp.app = this;

Now anywhere in your code you can access the application instance from MyApp.app.

3 Dec 2011, 3:43 PM

Which is a bug in PR2, and will be fixed before GA. But for now, that fixes it. :)

23 Jan 2012, 9:44 PM
Couldn't you also use Ext.getStore() and then filter it by the id property, or use findExact() if the id is unique? Or am I way off base.../:)