gridhyperlinkcolumn from autogenerated column

9 posts, 0 answers
  1. Ted
    Ted avatar
    47 posts
    Member since:
    Jan 2008

    Posted 02 Apr 2009 Link to this post

    I have an xml document formated like this that I am populating a grid with using Autogenerated columns.  the Google column does not show as a hyperlink.  is there a way to make the autogenerated hyperlink column?


    <?xml version="1.0" encoding="utf-16" ?>
    - <Users>
      <USER FirstName="Keith" MiddleName="A" LastName="Delman" Address1="" Address2="" City="Atlanta" State="Georgia" Zip="30301"  Google=http://www.google.com/search?hl=en&rls=GGLD,GGLD:2004-50,GGLD:en&q=%22Ted%20Slinkard%22+%22Oncology%22&spell=1 />
    </Users>
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 03 Apr 2009 Link to this post

    Hello Ted,

    I followed your scenario in order to replicate the issue but to no avail. Please find attached a small runnable application, which handles the desired functionality. Give it a try and let me know how it goes or if I am leaving something out.

    I hope this helps.

    Greetings,
    Pavlina
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ted
    Ted avatar
    47 posts
    Member since:
    Jan 2008

    Posted 03 Apr 2009 Link to this post

    I see what you are doing but I was hoping to get around modifying each row on Itemdatabound (just for performance as this will be a huge amount of data) but Thanks for the example.  I was wondering if with and XML document (not a database) if there was a way to formate the xml to tell the AutoGeneration to make it a hyperlink?
  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 06 Apr 2009 Link to this post

    Hello Ted,

    Note that runtime auto-generated columns will always appear after the user-specified columns, unless the columns are ordered programmatically.

    When the AutoGenerateColumns property is set to true, a GridBoundColumn object is automatically created for each field in the data source. Each field is then displayed as a column in the Telerik RadGrid control in the order that the fields appear in the data source. This option provides a convenient way to display every field in the data source; however, you have limited control of how an automatically generated column field is displayed or behaves.

    I hope this information helps.

    Greetings,
    Pavlina
    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  6. Ted
    Ted avatar
    47 posts
    Member since:
    Jan 2008

    Posted 17 Apr 2009 Link to this post

    OK.  this worked fine until I added a detail table to my grid.  now when I first load the grid it shows the linkbutton but when you click and expand to the detailtable, the mastertableview looses the link button formatting.  is there a way to keep this formatting in a hierachical grid?
  7. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 17 Apr 2009 Link to this post

    Hi Ted,

    Unfortunately I could not reproduce the issue you are facing. At this point in order to progress in the resolution of this matter, I will ask you to open a formal support ticket and send me a small project. It would allow me to track the issue locally.
    As soon as I do I will get back to you with additional information/suggestions.

    Best wishes,
    Pavlina
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 22 Jul 2009 Link to this post

    Ted, Pravlina,

    Did a support ticket get raised for this? If so, what was the outcome?

    I ask 'cos this is exactly what I'm seeing.

    --
    Stuart
  9. Ted
    Ted avatar
    47 posts
    Member since:
    Jan 2008

    Posted 22 Jul 2009 Link to this post

    Yes, I did get it working.  if you are using XML you will want a function similar to this.  hopefully that will help you also.

    protected

     

    void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)

     

    {

     

    if (e.Item is GridDataItem)

     

    {

    BuildLinks(e);

    }

    }


    private static void BuildLinks(GridItemEventArgs e)  
        {  
            GridDataItem item = e.Item as GridDataItem;  
            TableCell tb = item["Google"];  
            LinkButton lnk = new LinkButton();  
            lnk.ID = "lnk";  
            tb.Controls.Add(lnk);  
            if (item.DataItem != null)  
            {  
                XPathNavigator nav = ((IXPathNavigable)item.DataItem).CreateNavigator();  
                lnk.Attributes.Add("onClick""javascript:window.open('" + nav.GetAttribute("Google", nav.NamespaceURI) + "');return false;");  
            }  
            lnk.Text = "Google";  
            lnk.Attributes["href"] = "#";  
        } 
  10. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 22 Jul 2009 Link to this post

    Thanks Ted.

    Sadly, this doesn't solve my problem in that the links disappear if you interact with the grid.

    Back to the drawing board! :-)

    --
    Stuart
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017