如何使用ExtJS面板渲染器配置添加单击事件?

如何使用ExtJS面板渲染器配置添加单击事件?,extjs,Extjs,现在,在configs渲染器中,我不能调用tClick;有什么方法可以满足我的需求吗 代码是: Ext.application({ name: 'Fiddle', launch: function () { Ext.create('Ext.panel.Panel', { title: 'Table Layout', width: 300, layout: 'form',

现在,在configs渲染器中,我不能调用tClick;有什么方法可以满足我的需求吗

代码是:

Ext.application({
    name: 'Fiddle',

    launch: function () {
        Ext.create('Ext.panel.Panel', {
            title: 'Table Layout',
            width: 300,
            layout: 'form',
            items: [{
                xtype: 'displayfield',
                fieldLabel: 'Home',
                name: 'home_score',
                renderer: function (val) {
                    return "<button onclick='this.tClick;'>test</button>";
                }
            }],
            buttons: [{
                text: 'Upload',
                handler: this.tClick
            }],
            renderTo: Ext.getBody()
        });
    },

    tClick: function () {
        alert(1);
    },
});
Ext.application({
名字:“小提琴”,
启动:函数(){
Ext.create('Ext.panel.panel'{
标题:“表格布局”,
宽度:300,
布局:“表单”,
项目:[{
xtype:'displayfield',
fieldLabel:“主页”,
姓名:'主场得分',
渲染器:函数(val){
返回“测试”;
}
}],
按钮:[{
文本:“上传”,
handler:this.tClick
}],
renderTo:Ext.getBody()
});
},
t单击:函数(){
警报(1);
},
});

在此处查看运行结果:

您应该引用像
Fiddle.getApplication().tClick()这样的应用程序

Ext.application({
名字:“小提琴”,
启动:函数(){
让我=这个;
Ext.create('Ext.panel.panel'{
标题:“表格布局”,
宽度:300,
布局:“表单”,
项目:[{
xtype:'displayfield',
fieldLabel:“主页”,
姓名:'主场得分',
渲染器:函数(val){
返回“测试”;
}
}],
按钮:[{
文本:“上传”,
handler:this.tClick
}],
renderTo:Ext.getBody()
});
},
t单击:函数(){
警报(1);
},
});
Ext.application({
    name: 'Fiddle',

    launch: function () {
        let me =this;
        Ext.create('Ext.panel.Panel', {
            title: 'Table Layout',
            width: 300,
            layout: 'form',
            items: [{
                xtype: 'displayfield',
                fieldLabel: 'Home',
                name: 'home_score',
                renderer: function (val) {
                    return "<button onclick='Fiddle.getApplication().tClick();'>test</button>";
                }
            }],
            buttons: [{
                text: 'Upload',
                handler: this.tClick
            }],
            renderTo: Ext.getBody()
        });
    },

    tClick: function () {
        alert(1);
    },
});