单击网格列内的链接时调用函数

发布于 2025-01-06 08:07:32 字数 578 浏览 2 评论 0原文

我需要在网格内的链接上添加单击事件,这是如何工作的?

这是我的网格:

Ext.define('AM.view.advertiser.List', {
    extend:'Ext.grid.Panel',
    alias:'widget.advertiserlist',
    title:'All Advertisers',
    store:'Advertisers',
    columns: [
    {
            xtype:'gridcolumn',
            dataIndex:'clientname',
            text:'Clientname',
            width: 200,
            renderer: function(val) {
                    return '<a href="#">'+ val  +'</a>';
            }
    }]
});

在此处输入图像描述

I need to add a click event on a link inside the grid, how's that working?

This is my grid:

Ext.define('AM.view.advertiser.List', {
    extend:'Ext.grid.Panel',
    alias:'widget.advertiserlist',
    title:'All Advertisers',
    store:'Advertisers',
    columns: [
    {
            xtype:'gridcolumn',
            dataIndex:'clientname',
            text:'Clientname',
            width: 200,
            renderer: function(val) {
                    return '<a href="#">'+ val  +'</a>';
            }
    }]
});

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南笙 2025-01-13 08:07:32

以下是我如何破解相同的情况,但我希望控制器响应单击事件,并且我需要在井号标记后提取信息:

 'myView gridpanel[ref=myGrid]':{
                  itemclick : function(view, model, row, rowindex, event) {
                        var hash = event.getTarget().hash;
                        if (!hash && event.getTarget().parentNode) {
                            hash = event.getTarget().parentNode.hash
                        }
                      if(hash) {
                          console.log("Control: "+hash);
                          //do something with the hash -> #{mydata}
                      }
                  }

             }

Here is how I hacked the same exact situation, but I wanted controller to respond to the click events and I needed to extract info after the hashmark:

 'myView gridpanel[ref=myGrid]':{
                  itemclick : function(view, model, row, rowindex, event) {
                        var hash = event.getTarget().hash;
                        if (!hash && event.getTarget().parentNode) {
                            hash = event.getTarget().parentNode.hash
                        }
                      if(hash) {
                          console.log("Control: "+hash);
                          //do something with the hash -> #{mydata}
                      }
                  }

             }
Saygoodbye 2025-01-13 08:07:32
xtype:'gridcolumn',
dataIndex:'clientname',
text:'Clientname',
width: 200,
autoEl:{
    tag: 'a',
    href: '',
    onClick: 'nameYouFunction',
    //Any methods to add here
}
xtype:'gridcolumn',
dataIndex:'clientname',
text:'Clientname',
width: 200,
autoEl:{
    tag: 'a',
    href: '',
    onClick: 'nameYouFunction',
    //Any methods to add here
}
暗恋未遂 2025-01-13 08:07:32

您可以使用以下事件:
http://docs.sencha .com/extjs/4.1.1/#!/api/Ext.grid.Panel-event-cellclick
之后,您可以使用事件的参数使其按您想要的方式工作

You can use the following event:
http://docs.sencha.com/extjs/4.1.1/#!/api/Ext.grid.Panel-event-cellclick
And after that, you can use parameters of the event to make it work as you want

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文