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

Rad Grid Hyperlink column - Right click context menu

3 Answers 486 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Penny
Top achievements
Rank 1
Penny asked on 24 Sep 2008, 11:24 PM

I built a grid that has a hyperlink column and also a context menu associated to it. The hyperlink column was added to the grid in codebehind when the grid was built ( needed to built the grid in code behind to control what columns would show dynamically). The column was added fine but I had to manually create the hyperlink that would be placed on the grid so I can add attributes to it. I set the "onmouseover" attribute for example.

The problem is that I can open the context menu associated to the grid from anywhere on a row except on the hyperlink column Text. Anywhere around the text withing the column works fine too. Is there an attribute that I have to set? Or is there a certain way I have to build the hyperlink column? Or is the context menu even able to load from a right click on a hyperlink?

Any advise or assitance would be very appreciated.

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 26 Sep 2008, 04:57 PM
Hello Penny,

Unfortunately I was unable to reproduce the described behavior on my local machine. I have attached a simple test project which re-creates your scenario. Can you please take a look, maybe I'm missing something obvious?

Regards,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Penny
Top achievements
Rank 1
answered on 26 Sep 2008, 06:56 PM
Thanks for the reply. I took a look at the sample code you sent and I noticed a difference. I build the grid and hyperlink column in code behind while you build it in the designer. I do not know if this would make a difference or not.

Here is some of the code I used to build the hyperlink column in code behind:

 Dim oHyperLinkColumn As New Telerik.Web.UI.GridHyperLinkColumn
          uxradgrid.MasterTableView.Columns.Add(oHyperLinkColumn)
          With oHyperLinkColumn
                .HeaderText = " Number "
                .SortExpression = "ServiceOrderNo"
                .DataTextField = "ServiceOrderNoHL"
                .UniqueName = "ServiceOrderNoHL"
                .ItemStyle.ForeColor = Color.Blue
                .ItemStyle.HorizontalAlign = HorizontalAlign.Center
                 .Visible = True
            End With

In the itemdatabound event I added the text to the column.

  '' Set the hyperlink in the column
  Dim hLink As HyperLink = CType(dataBoundItem.Item("SOrNohl").Controls(0), HyperLink)
                    Dim Datakey As String = dataBoundItem.OwnerTableView.DataKeyValues(0)("SOID").ToString()
                    With hLink
                        If m_IsServiceOrders Then
                            .Attributes.Add("onclick", "javascript:NewWindow('Dispatch.aspx?ObjectID=" + dataBoundItem.Item("SOID").Text + "&daydate=" + hlinkStartDate + "&NewRad=true',800,500,'true'); return false;")
                        ElseIf m_IsCalls Then
                            .Attributes.Add("onclick", "javascript:NewWindow('CPage.aspx?CID=" + dataBoundItem.Item("CID").Text + "&daydate=" + hlinkStartDate + "&SOID=" + dataBoundItem.Item("SOID").Text + "',800,500,'true'); return false;")
                        Else
                            .Attributes.Add("onclick", "javascript:NewWindow('APage.aspx?AID=" + dataBoundItem.Item("AID").Text + "&CID=" + dataBoundItem.Item("CID").Text + "&daydate=" + hlinkStartDate + "',800,500,'true'); return false;")
                        End If
                        .Attributes.Add("onmouseover", "this.style.cursor='hand'")
                        .NavigateUrl = ""
                        .ForeColor = Color.Blue
                        .Font.Bold = True
                        .Font.Underline = True
                        .Visible = True
                        .Text = dataBoundItem.Item("SONo").Text
                    End With


For the Text of the column, I gave it the text of another column's data.

Or is there a way to bind the hyper link column to a specific column from the datasource so that the data from the column is displayed as a hyperlink?

Thanks again.







0
Rosen
Telerik team
answered on 29 Sep 2008, 12:58 PM
Hi Penny ,

I'm afraid that I'm still unable to reproduce this behavior locally. Can you please check that you are using the latest version of RadGrid control?

Best wishes,
Rosen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Penny
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Penny
Top achievements
Rank 1
Share this question
or