Sencha touch 2 如何在XTemplate(itemTpl)中调用视图函数

Sencha touch 2 如何在XTemplate(itemTpl)中调用视图函数,sencha-touch-2,Sencha Touch 2,关于这一点,有几个问题是可行的,但在我的场景中不要这样做。 我想调用在我的超类视图中定义的函数,而不是调用itemTpl本身中的函数。 我在itemTpl中有类似的内容: '<span class="x-button-label" style="" id="ext-element-115">{[this.getTranslation("textcodestr", "Text by default")]}</span>', 它可以工作,但我希望将此函数移动到视图的超类,并

关于这一点,有几个问题是可行的,但在我的场景中不要这样做。 我想调用在我的超类视图中定义的函数,而不是调用itemTpl本身中的函数。
我在itemTpl中有类似的内容:

'<span class="x-button-label" style="" id="ext-element-115">{[this.getTranslation("textcodestr", "Text by default")]}</span>',
它可以工作,但我希望将此函数移动到视图的超类,并能够在模板中调用该函数,而不是在所有应用程序模板中复制和粘贴。
当然,使用超长线执行函数中的操作并不理想。

有办法做到这一点吗?

谢谢

Milton

我通过使用singleton助手解决了这个问题,我可以从itemTpl调用它

Ext.define('MyApp.util.Shared', {
singleton : true,

getTranslation: function (textCode, defaultText) {
     var store = Ext.getStore('TranslationsStore');
     var index = store.findExact('TextCode', textCode)
     if (index > -1) {
          return store.getAt(index).data.TextTranslated;
     }
     return defaultText;
}});
然后,在itemTpl中

'<span class="x-button-label" style="" id="ext-element-115">{[MyApp.util.Shared.getTranslation("textcodestr", "Text by default")]}</span>',
'{[MyApp.util.Shared.getTranslation(“textcodestr”,“默认文本”)]},

弥尔顿

'<span class="x-button-label" style="" id="ext-element-115">{[MyApp.util.Shared.getTranslation("textcodestr", "Text by default")]}</span>',