Extjs Sencha Touch 2:如何创建全局内联xtemplate配置方法?
在我心目中的理想世界中,我会在我的Extjs Sencha Touch 2:如何创建全局内联xtemplate配置方法?,extjs,sencha-touch-2,Extjs,Sencha Touch 2,在我心目中的理想世界中,我会在我的Ext.dataview.List: itemTpl: '{name:customFunction}' 其中customFunction是全局/静态函数,我可以在所有模板上重用。现实世界中最接近的解决方案是什么?最接近的是按照你说的去做。。。只需将自定义函数添加到Ext.util.Format 例如: Ext.define(null, { override: 'Ext.util.Format' ,customFunction: functio
Ext.dataview.List
:
itemTpl: '{name:customFunction}'
其中customFunction是全局/静态函数,我可以在所有模板上重用。现实世界中最接近的解决方案是什么?最接近的是按照你说的去做。。。只需将自定义函数添加到
Ext.util.Format
例如:
Ext.define(null, {
override: 'Ext.util.Format'
,customFunction: function(value, append) {
return 'This is it: '
+ value
+ (Ext.isDefined(append) ? append : ''); // you can use args too
}
});
最接近的是按照你说的去做。。。只需将自定义函数添加到
Ext.util.Format
例如:
Ext.define(null, {
override: 'Ext.util.Format'
,customFunction: function(value, append) {
return 'This is it: '
+ value
+ (Ext.isDefined(append) ? append : ''); // you can use args too
}
});
这可能是你最好的选择:
itemTpl: new Ext.XTemplate(
'{[this.getGlobalValue()]}',
{
getGlobalValue: MyApp.util.Utils.globalTplFunction
}
)
然后,在Utils文件中:
Ext.define('MyApp.util.Utils', {
singleton: true,
globalTplFunction: function() {
//do whatever here
return "Result!";
}
});
这可能是你最好的选择:
itemTpl: new Ext.XTemplate(
'{[this.getGlobalValue()]}',
{
getGlobalValue: MyApp.util.Utils.globalTplFunction
}
)
然后,在Utils文件中:
Ext.define('MyApp.util.Utils', {
singleton: true,
globalTplFunction: function() {
//do whatever here
return "Result!";
}
});
令人惊叹的!我制作了
Ext.define('Tm.ux.Format',{
),它就像一个charmSweet,这正是我想要的。太棒了!我制作了Ext.define('Tm.ux.Format',{
),它就像一个charmSweet,这正是我想要的。