I'm using Sencha Architect 3 for my project, and I have an XTemplate in my ComboBox. I'd like to use a function in it, and it's all good, until I want the use the combobox in my function. As I read it here: http://www.sencha.com/forum/showthread.php?157022-scope-in-XTemplate-function , I can change the scope of the function and thats all I need.
My problem is, that I can't set the scope in Architect. Is there any way to do it?
Ext.define('APP.view.MyCombo', {
extend: 'Ext.form.field.ComboBox',
alias: 'widget.mycombo',
requires: [
'Ext.view.BoundList',
'Ext.XTemplate'
],
initComponent: function() {
var me = this;
Ext.applyIf(me, {
listConfig: {
xtype: 'boundlist',
itemSelector: 'div',
itemTpl: Ext.create('Ext.XTemplate',
'{[this.getName(values)]}',
{
scope: scope, // I can't set this in architect
getName: function(record) {
console.log(this); // I need to use the combo here
}
}
)
}
});
me.callParent(arguments);
}
});
I'm on the Architect team and I happened to run across your question here, although I'd suggest in general that people post to the Sencha Architect forums for consistent official support rather than here on SO. Still we're always happy to help!
Your best bet here is to use the "me" variable since Architect doesn't presently allow you to set the scope. If you need to access something out of that scope, in most cases you should be able to get there via 'me' one way or the other.
I recognize that's not quite the ideal answer you're after, and we certainly take feedback seriously in terms of features our users need, etc.