Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/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 如何使用Ext.js 4.2在渲染器html中调用函数_Extjs - Fatal编程技术网

Extjs 如何使用Ext.js 4.2在渲染器html中调用函数

Extjs 如何使用Ext.js 4.2在渲染器html中调用函数,extjs,Extjs,代码是: Ext.define("Myapp", { extend: '', config: {}, initComponent: function () {}, getGrid: function () { Ext.create("Ext.grid.Panel", { ... columns: [ { header: 'xx', renderer: function (value) {

代码是:

Ext.define("Myapp", {
  extend: '',
  config: {},

  initComponent: function () {},

  getGrid: function () {
    Ext.create("Ext.grid.Panel", {
      ...
      columns: [
        {
          header: 'xx',
          renderer: function (value) {
            return '<a onclick=''>text</a>';
          }
        }
      ]
    });
  },

  test: function(){
    alert(1);
  },
});
Ext.define(“Myapp”{
扩展:“”,
配置:{},
initComponent:函数(){},
getGrid:函数(){
Ext.create(“Ext.grid.Panel”{
...
栏目:[
{
标题:“xx”,
渲染器:函数(值){
返回“文本”;
}
}
]
});
},
测试:函数(){
警报(1);
},
});
在上面的代码中,我希望在onclick事件中调用test函数。我尝试了Myapp.test(),但没有成功


有什么方法可以做到这一点吗?

如果用户单击了“a”标记,您必须向单元格中添加一个侦听器,并在侦听器函数中进行检查

这是一个很好的例子

看看这个

ExtJS组件的工作方式类似于简单的对象文字,因此您可以使用任何您想要的方式对其进行扩展。在本例中,我添加了属性“active”,可以在beforeEdit侦听器中检查该属性


您可以在某个实用程序文件中创建全局函数,然后仅以字符串形式调用此函数。