Wire to GridViewHyperlinkColumn Click Event

4 posts, 0 answers
  1. Ernie S
    Ernie S avatar
    33 posts
    Member since:
    Apr 2014

    Posted 28 Jan 2015 Link to this post

    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
  2. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 30 Jan 2015 Link to this post

    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.

     
  3. DevCraft banner
  4. Ernie S
    Ernie S avatar
    33 posts
    Member since:
    Apr 2014

    Posted 30 Jan 2015 in reply to Stefan X1 Link to this post

    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
  5. Stefan X1
    Admin
    Stefan X1 avatar
    514 posts

    Posted 30 Jan 2015 Link to this post

    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.

     
Back to Top