extjs - 如何使用 ExtJS 面板渲染器配置添加点击事件?
问题描述
现在,在配置渲染器中,我不能调用 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);
},
});
在此处查看运行结果:https ://fiddle.sencha.com/#view/editor
解决方案
您应该参考应用程序,例如Fiddle.getApplication().tClick()
.
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);
},
});
推荐阅读
- python - 如何将字符串中的“未定义”替换为 0?
- javascript - 如何添加在 React 组件中编辑文本的功能?
- java - 无法删除以 UUID 作为 ID 的实体
- regex - SilverStripe .htaccess 在不更改 URL 的情况下重定向到不同的页面不起作用
- javascript - Javascript 游戏命中检测仅适用于第一个对象
- python - 使用savefig和sendfile在烧瓶中绘制多个Sns图扭曲
- python - 使用 tkinter 按钮执行文件并在文本字段上打印输出
- unicode - 在希伯来文字母上放置一个阿拉伯 shadda
- python - 如何优化代码的运行时间和内存使用以查找最长的子字符串?
- amazon-web-services - AWS CDK:将特定 S3 资源添加到 IAM 策略