Custom event for GridViewHyperlinkColumn

1 Answer 45 Views
GridView
James DAmour
Top achievements
Rank 1
James DAmour asked on 17 Oct 2022, 08:20 AM

Is there a way to have a custom event on a GridViewHyperlinkColumn and disable the primary default behavior?

Currently I can add a handler to the Hyperlink.Click event, but the control seems to always have the default click event enabled.

For example, if my custom event opens a link, then the above behavior ends up opening duplicate links.

 

Thanks,

Nelson

James DAmour
Top achievements
Rank 1
commented on 18 Oct 2022, 07:18 PM

As a workaround, I used a button in a datacolumn to achieve the desired functionality although the styling isn't exactly like the natural expectation of a hyperlink.

1 Answer, 1 is accepted

Sort by
0
Accepted
Stenly
Telerik team
answered on 19 Oct 2022, 05:29 PM

Hello Nelson,

Indeed, one way to achieve this functionality would be to add a column that is not the GridViewHyperlinkColumn and create a custom CellTemplate for it. This will allow you to subscribe to the Clicked event of the control and implement the needed functionality. However, instead of using a Button, may I ask if you could try the RadHyperlinkButton element instead? 

The following code snippet shows a sample implementation of this suggestion:

<telerik:RadGridView Name="gridView" AutoGenerateColumns="False">
    <telerik:RadGridView.Columns>
        <telerik:GridViewColumn>
            <telerik:GridViewColumn.CellTemplate>
                <DataTemplate>
                    <telerik:RadHyperlinkButton Content="Hi"/>
                </DataTemplate>
            </telerik:GridViewColumn.CellTemplate>
        </telerik:GridViewColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

This will produce the following result:

Would it be possible to give this suggestion a try?

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

James DAmour
Top achievements
Rank 1
commented on 20 Oct 2022, 11:26 PM

Hi Stenly,

Your suggestion is good, I tested it out as well. Thanks for the tip!

Regards,

Nelson

 

Tags
GridView
Asked by
James DAmour
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or