如何在ExtJs中从tpl调用函数
我正在使用dataview控件,需要从其tpl调用函数。 下面是我的代码,但它不工作如何在ExtJs中从tpl调用函数,extjs,extjs7,Extjs,Extjs7,我正在使用dataview控件,需要从其tpl调用函数。 下面是我的代码,但它不工作 xtype: 'dataview', scrollable: true, tpl: new Ext.XTemplate(
xtype: 'dataview',
scrollable: true,
tpl: new Ext.XTemplate(
'<tpl for=".">',
'<div class="messageTbl">',
'<table style="width: 100%;">',
'<tr><td>{[this.formatDate(CreationDate)]}</td><tr/>',
'</table>',
'</div>',
'</tpl>',
{
formatDate: function (date) {
return date;
}
},
}
),
xtype:'dataview',
可滚动:对,
tpl:新Ext.XTemplate(
'',
'',
'',
“{[this.formatDate(CreationDate)]}”,
'',
'',
'',
{
formatDate:函数(日期){
返回日期;
}
},
}
),
您在formattate
函数中有语法错误
{
xtype:“数据视图”,
可滚动:对,
tpl:新Ext.XTemplate(
'',
'',
'',
“{[this.formatDate(CreationDate)]}”,
'',
'',
'',
{
formatDate:函数(日期){
返回日期;
}
}
)
}
在同一示例中要求索引:
这在XTemplate文档的摘要部分
var tpl=new Ext.XTemplate(
“孩子:”,
'',//处理data.kids节点
“{#}.{name}”,//使用当前数组索引自动编号
“”
);
tpl.overwrite(panel.body,data.kids);//传递数据对象的kids属性
它在吗?我们能在同一个例子中得到索引@norbeq吗?
var tpl = new Ext.XTemplate(
'<p>Kids: ',
'<tpl for=".">', // process the data.kids node
'<p>{#}. {name}</p>', // use current array index to autonumber
'</tpl></p>'
);
tpl.overwrite(panel.body, data.kids); // pass the kids property of the data object