Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ExtJs中从tpl调用函数_Extjs_Extjs7 - Fatal编程技术网

如何在ExtJs中从tpl调用函数

如何在ExtJs中从tpl调用函数,extjs,extjs7,Extjs,Extjs7,我正在使用dataview控件,需要从其tpl调用函数。 下面是我的代码,但它不工作 xtype: 'dataview', scrollable: true, tpl: new Ext.XTemplate(

我正在使用dataview控件,需要从其tpl调用函数。 下面是我的代码,但它不工作

                                        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