3

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

Julian Hollmann
  • 2,902
  • 2
  • 25
  • 44

3 Answers3

1

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}
                      }
                  }

             }
dbrin
  • 15,525
  • 4
  • 56
  • 83
0
xtype:'gridcolumn',
dataIndex:'clientname',
text:'Clientname',
width: 200,
autoEl:{
    tag: 'a',
    href: '',
    onClick: 'nameYouFunction',
    //Any methods to add here
}
Roberto Pegoraro
  • 1,313
  • 2
  • 16
  • 31
0

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

Sangnc
  • 26
  • 1