-
2 Dec 2011 8:00 AM #1
Question about XTemplate usage in a view config
Question about XTemplate usage in a view config
Hi,
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:
I need to look up some values in another store in my application based on a value being passed into the XTemplate member function.Code:Ext.define('PinpointersTouch.view.UnitList', { extend: 'Ext.List', xtype: 'unitslist', config: { fullscreen: true, itemTpl: new Ext.XTemplate( '<ul id="unitList">', '<tpl for=".">', '<li>', '<table width="100%" cellspacing="0">', '<tr>', '<td style="width:30px; text-align:center">{[this.getUnitIcon(values.id)]}</td>', '<td valign="middle"> - {UnitName}</td>', '</tr>', '</table>', '</li>', '</tpl>', '</ul>', { 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' } });
-
2 Dec 2011 9:37 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 435
Yes and no.
By default, the application instance isn't cached anymore so in your launch method you can cache it on your namespace:
Now anywhere in your code you can access the application instance from MyApp.app.Code:Ext.application({ name : 'MyApp', launch : function() { MyApp.app = this; } });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
3 Dec 2011 3:43 PM #3
^^^
Which is a bug in PR2, and will be fixed before GA. But for now, that fixes it.
Sencha Inc.
Robert Dougan - @rdougan
Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.
-
23 Jan 2012 9:44 PM #4
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...



Reply With Quote