[英]Is it possible to combine two Ext.XTemplate together?
我有一個xtype,它接受兩個將應用於一組值的Ext.XTemplates(一個是必需的,一個是可選的)。 不幸的是,我無法實現這一點,因為最后運行的模板將覆蓋值。 是否可以將XTemplate附加到另一個模板中,或使其在一組值上一個接一個地運行而不破壞先前應用的模板?
這是我的Ext.grid.Column擴展類:
LinkColumn = Ext.extend(Ext.grid.Column,{
href: '',
additionalTemplate: '',
forceApplyTemplate:false,
dateFormat: 'm/d/y H:i',
constructor: function(config){
Ext.QuickTips.init();
var tpl = new Ext.XTemplate(
'<tpl if="this.hasValue('+config.dataIndex+') == true">',
'<tpl if="this.isDate('+config.dataIndex+') == false">',
'<a href="'+config.href+'">{'+config.dataIndex+'}</a>',
'</tpl>',
'<tpl if="this.isDate('+config.dataIndex+') == true">',
'<a href="'+config.href+'">{[fm.date(values.'+config.dataIndex+',"'+this.dateFormat+'")]}</a>',
'</tpl>',
'</tpl>',
{
compiled: true,
hasValue: function(value){
return !Ext.isEmpty(value);
},
isDate: function(value){
return Ext.isDate(value);
}
}
);
LinkColumn.superclass.constructor.call(this,config);
if (Ext.isEmpty(this.href)) { throw new Ext.Error('LinkColumn: href property is required') };
this.renderer = function(value, p, r){
if (!Ext.isEmpty(this.additionalTemplate)){
var moreTemplate = (!Ext.isPrimitive(this.additionalTemplate) && this.additionalTemplate.compile) ? this.additionalTemplate : new Ext.XTemplate(this.additionalTemplate);
value = (!Ext.isEmpty(moreTemplate)) ? moreTemplate.apply(r.data) : value;
value = moreTemplate.apply(r.data);
};
//here where value gets overwritten:
value = tpl.apply(r.data);
return value;
};
},
});
值是template.apply返回的HTML字符串,對嗎? 你不能簡單地做:
value += tpl.apply(r.data);
哪個將第二個模板的結果添加到第一個模板的結果中?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.