• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

How to track hyperlink as event in grid cell?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to track hyperlink as event in grid cell?

    Hi,
    A column of a grid contains a set of composite data that includes a hyperlink. For example a text block that has an embedded link. Is there a way for me to track the clicking of the hyperlink as a trigger to fire off an event on the app instead of sending the user to the linked destination as the link intended?
    Thanks,

  • #2
    I would suggest not creating it as a hyperlink if you do not want it to behave as a hyperlink.

    Instead, you can use a bit of css and html to accomplish what you are after.

    Column renderer
    Code:
    return '<div class="looks-like-hyperlink" data-event="myevent">SOMETEXT</div>
    Add a cell click listener to your grid.

    Code:
    onCellClick : function(cmp, td, cellIndex, rec, tr, rowIndex, e){
        var me    = this,
            el    = Ext.get(e.getTarget()),
            event = el.getAttribute('data-event');
    
        if (event){
           me.fireEvent(event);
        }
    }

    Comment


    • #3
      Sean,
      Thanks for the quick response. I will try that.
      A follow-up question: if there are more than 1 "link" in the same text block, how does the program distinguish which link a user selected?

      Comment


      • #4
        It would be based off the data-event value you supplied. So if you have multiple dom elements then make sure data-event value is unique so you know which one the user clicked.

        Comment

        Working...
        X