javascriptextjsextjs4extjs4.2

Column render, listen to click event of a <i> tag


I have a render function on a grid column that basically returns some html, the html consists of a <i> tag to display an icon and then some text. Sort of like this:

 <i class="some class"> </i> some text

I only want to attach a click event to the <i> tag, not the text, so itemClick wouldn't work. How do I attach an element listener just to the <i> tag that is returned from my render function ?

I did look at use a columnaction but I can only use an img, and no text can be set after the image.


Solution

  • Listen for the cellclick event, then check the event target:

    listeners: {
        cellclick: function(grid, td, cellIndex, record, tr, rowIndex, e) {
            if (cellIndex === whatever && Ext.fly(e.target).hasCls('foo')) {
                 // Go
            }
        }
    }