I would like a WinGrid (in NA 2009.1) to have one or more hyperlink columns that display "Click here" (with no editing). Upon clicking on the cell, I need to navigate to a URL.
What is the recommended method for doing this, including the recommended method for storing (and stuffing) the URL for the cell.
Thanks,
Tom K.
Hi Tom,
You can set the Style on the Column to Formatted and populate it with some xml to provide a link.
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridColumn myURLColumn = e.Layout.Bands[0].Columns.Add("My URL Column"); myURLColumn.Style = Infragistics.Win.UltraWinGrid.ColumnStyle.FormattedText; } private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e) { if (e.Row.Band.Index == 0) { if (e.Row.Cells.Exists("My URL Column")) { e.Row.Cells["My URL Column"].Value = "<a title=\"Click here to go to Infragistics web site.\" href=\"http://www.Infragistics.com\">Click here</a>"; } } }
Hi Mike,
I found this post because I am trying to do the same thing. However, I'm having some issues on links with query strings. It appears that the formatted text does not turn into a link in the grid when the href contains an ampersand. It does work when the field is styled as a URL instead of the formatted text (but then I can't use different text for the display portion of the link). Here is the link that is not being changed:
http://www.ngc.gov/summary/summary.aspx?doc_id=13164&nbr=006727&string=lipid+AND+screening
and the cell is displaying:
<a href="http://www.ngc.gov/summary/summary.aspx?doc_id=13164&nbr=006727&string=lipid+AND+screening">Test</a>
And the code to spit this out is in the InitializeRow event:
e.Row.Cells(
""">Test</a>"
Is there some kind of encoding that I need to do on the value, or is this a bug?
Mike
I tested this out and I get the same results. It looks like a bug to me.
I am going to forward this thread to Infragistics Developer Support so they can have it looked into.
Hi,
It just occurred to me that ampersand is used for some escape codes in XML. For example, "<" is used for a Less Than sign.
So you might have to replace your ampersands with the proper escape code for an ampersand, which I beleive is "&"
Encoding the ampersands did it. Thanks for your help. That's a lot easier than having to install a patch.
Thanks.