This is a migrated thread and some comments may be shown as answers.

Setting the OnClick event of a GridHyperLink Column from the Client-Side

2 Answers 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 14 Nov 2012, 07:08 PM
Telerik,

I have a RadGrid that is bound on the client-side.  I would like to access the hyperlinkcolmn in the RowDataBount (client-side) function at set the "click" event.  I am having all sorts of trouble getting to the correct control.  Can you help me out?

Here is the HyperLinkColumn
<telerik:GridHyperlinkColumn UniqueName="RequestNumber" HeaderText="Request #" SortExpression="RequestNumber"
DataTextField="RequestNumber" HeaderStyle-Width="6em" AllowFiltering="false" />

Here is the client-side function I want to use to access the lyperlink click event:

   this.RowDataBound = function(sender, args) {
        var item = args.get_item();
        var dataItem = args.get_dataItem();
        var rowNumber = parseInt(item._itemIndexHierarchical);
};


2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 14 Nov 2012, 08:06 PM
Hello,

function RowDataBound(sender, args) {
               var yourlink = args.get_item().get_cell("RequestNumber").getElementsByTagName('a');
               // Access your link here
           }


Thanks,
Jayesh Goyani
0
Chris
Top achievements
Rank 1
answered on 14 Nov 2012, 08:21 PM
Jeyesh,

Thanks for the reply.  It turns out that you are correct.  It was the accessing the link (having no intellisense) that was the trick.  The following code is the complete solution to my question.
var link = item.get_cell("RequestNumber").getElementsByTagName("a")[0];
    link.href = "javascript:void(0);";
    link.onclick = function () {
        SecurelyNavigateTo(dataItem["RequestNumber"]);
    };

Tags
Grid
Asked by
Chris
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Chris
Top achievements
Rank 1
Share this question
or