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

Integrate with ContextMenu

4 Answers 226 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joshua Gates
Top achievements
Rank 1
Joshua Gates asked on 02 Jan 2008, 05:52 PM
I have a HyperLink template column in my grid. I am wanting to add in a right-click contextmenu  on the the hyperlink.

Any ideas on how to achieve this.

Joshua

4 Answers, 1 is accepted

Sort by
0
Joshua Gates
Top achievements
Rank 1
answered on 02 Jan 2008, 05:53 PM
this is wierd i got it to work however, it is only showing for the first item in grid
0
Joshua Gates
Top achievements
Rank 1
answered on 02 Jan 2008, 06:06 PM
ignore i asked pre-maturely...i got it working
0
Jakub Wilk
Top achievements
Rank 2
answered on 09 Jan 2008, 01:11 PM
can you share the solution,

we have 2 context menu and grid,

everything works besides hyperlink that is within grid,
0
Joshua Gates
Top achievements
Rank 1
answered on 09 Jan 2008, 03:13 PM
yep here is one of the columns

<radG:GridTemplateColumn HeaderText="Contact" UniqueName="colContact" SortExpression="contactName">
                                <ItemTemplate>                                  
                                   <asp:HyperLink runat="server" id="lnkContact"></asp:HyperLink>    
                                    <telerik:RadContextMenu runat="server" Skin="Office2007" ID="radContactMenu">
                                        <Targets>
                                            <telerik:ContextMenuControlTarget ControlID="lnkContact" />
                                        </Targets>
                                        <Items>
                                            <telerik:RadMenuItem runat="server" id="createTicketItem" Text="Create Ticket" Value="createTicket"></telerik:RadMenuItem>    
                                            <telerik:RadMenuItem runat="server" id="showTickets" Text="Show Tickets" Value="showTickets"></telerik:RadMenuItem>                                        
                                        </Items>
                                    </telerik:RadContextMenu>
                                </ItemTemplate>
                             </radG:GridTemplateColumn>       

and in the code behind on the ItemDataBound Event

Telerik.Web.UI.RadContextMenu tmpMenu = (Telerik.Web.UI.RadContextMenu)e.Item.FindControl("radContactMenu");
                         if (tmpMenu != null)
                         {
                             Telerik.Web.UI.ContextMenuControlTarget mnuTarget = (Telerik.Web.UI.ContextMenuControlTarget)tmpMenu.Targets[0];
                             mnuTarget.ControlID = ((e.Item as Telerik.WebControls.GridDataItem)["colContact"].FindControl("lnkContact") as HyperLink).ClientID;
                             Telerik.Web.UI.RadMenuItem menuItem = tmpMenu.FindItemByValue("createTicket");
                             Telerik.Web.UI.RadMenuItem menuShowItem = tmpMenu.FindItemByValue("showTickets");
                             if (menuItem != null)
                             {
                                                                   menuItem.NavigateUrl = "~/ticket/ticket.aspx?contID=" + contactID;
                                     menuShowItem.NavigateUrl = "~/ticket/findTicket.aspx?contID=" + contactID;
                             }
                         }

hope this helps let me know if not
Tags
Grid
Asked by
Joshua Gates
Top achievements
Rank 1
Answers by
Joshua Gates
Top achievements
Rank 1
Jakub Wilk
Top achievements
Rank 2
Share this question
or