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

Wire to GridViewHyperlinkColumn Click Event

3 Answers 99 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ernie S
Top achievements
Rank 1
Ernie S asked on 28 Jan 2015, 09:34 PM
I am trying to create columns dynamically in code for a RadGridView.  So something like this:

01.AssociatedObject.Columns.Clear();
02.var col = new GridViewHyperlinkColumn
03.{
04.    DataMemberBinding = new Binding(hcol.ColumnName),
05.    IsReadOnly = hcol.IsReadOnly,
06.    Header = hcol.Header,
07.    Width = hcol.Width,
08.    DataFormatString = hcol.DataFormatString
09.};
10. 
11.//AssociatedObject is a RadGridView
12.var columns = AssociatedObject.Columns;
13.columns.Add(col);

I would like to also wire in code so that when the link is clicked it fires an event handler in code. Since it is being added this way I cannot easily set any kind of template or style that binds to any kind of command.  I tried using AddHandler at various parts of GridView but cannot seem to it in the right spot.  I am suprised the GridViewHyperlinkColumn object does not have an Event of any kind. Any way to make this work?

Thanks for any help.

Ernie

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 30 Jan 2015, 09:55 AM
Hello Ernie,

For your scenario I can suggest you to implement your custom HyperLinkDataItem class with a custom Command for handling the click event. Then you could use this class within a CellTemplate for a GridViewDataColumn. Please check the attached project for further reference.

Kind Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ernie S
Top achievements
Rank 1
answered on 30 Jan 2015, 02:23 PM
Thanks for the info Stefan.  But, like I said, I am trying to avoid any kind of template or style since they are not easy to create in code (deprecated methods or string manipulation).  A simple Click event for the Hyperlink Column object would be prefect but it seems it does not exists.

I ended up just creating a datatemplate in XAML and then pulling it into code via URI.

Thanks for the help.

Ernie
0
Stefan
Telerik team
answered on 30 Jan 2015, 04:34 PM
Hello Augistine,

I am glad to hear you have a workaround suitable for your requirements.

Do not hesitate to contact us if you have any other questions on our controls.

Best Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Ernie S
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Ernie S
Top achievements
Rank 1
Share this question
or