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

[Solved] RadGrid + ContextMenu + RadWindow Integration

3 Answers 479 Views
Grid
This is a migrated thread and some comments may be shown as answers.
KevinMc
Top achievements
Rank 1
KevinMc asked on 14 Feb 2008, 08:52 PM
I am trying to add an image to a radgrid column that when hovered or clicked opens a context menu. The context menu contains a series of commands that i want to launch rad windows based on the command clicked and the datakey of the grid row.

I have found examples doing each thing individually but none that do this all together. Below is the code i am using. The showMenu Portion works fine. Now how do i get the contextmenuitem clicked and the datakeyname for the row it was clicked in so i can determine which radwindows to open pass it the productid for the row the contextmenu was clicked on?

Thanks for any help,
Kevin


<script type="text/javascript">  
       function showMenu(e)  
       {  
               var contextMenu = $find("<%= RadContextMenu1.ClientID %>");  
               if ((!e.relatedTarget) || (!Telerik.Web.DomUtility.isDescendantOrSelf(contextMenu.get_element(), e.relatedTarget)))  
               {  
                       contextMenu.show(e);  
               }  
               Telerik.Web.DomElement.cancelRawEvent(e);  
       }  
          
       function openDeleteWindow(ProductID)  
       {  
           var oPWResetWnd = radopen("../DeleteProductRequest.aspx?ProductID=" +ProductID, "RadWindow1" );  
           oPWResetWnd.Center();  
           oPWResetWnd.setSize(800,600);  
       }  
</script> 

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
    </telerik:RadScriptManager> 
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" AllowSorting="True" 
        GridLines="None">  
        <MasterTableView TableLayout="Auto" AutoGenerateColumns="False" 
            DataKeyNames="Product">  
            <Columns> 
                <telerik:GridTemplateColumn UniqueName="TemplateColumn">  
                    <ItemTemplate> 
                    <asp:Image ID="imgManage" runat="server" ImageUrl="~/Images/v3_btn_manage.gif"   
                        onmouseover="showMenu(event)" onclick="showMenu(event)" alt="" /> 
                    </ItemTemplate> 
                </telerik:GridTemplateColumn> 
            </Columns> 
        </MasterTableView> 
        <ClientSettings> 
            <Selecting AllowRowSelect="True" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="WebBlue" Width="600px" 
        Height="400px" /> 
    <telerik:RadContextMenu ID="RadContextMenu1" runat="server" Flow="Horizontal">  
        <Items> 
            <telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Text="Edit">  
                <GroupSettings ExpandDirection="Auto" Flow="Vertical" /> 
            </telerik:RadMenuItem> 
            <telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Text="Delete">  
                <GroupSettings ExpandDirection="Auto" Flow="Vertical" /> 
            </telerik:RadMenuItem> 
        </Items> 
    </telerik:RadContextMenu> 
 
 



3 Answers, 1 is accepted

Sort by
0
KevinMc
Top achievements
Rank 1
answered on 18 Feb 2008, 02:25 PM
Any suggestions on this or should i start looking for an alternate design for this page?
0
Sebastian
Telerik team
answered on 18 Feb 2008, 03:07 PM
Hi KevinMc,

What I can suggest is to display the context menu when right-clicking a grid record (instead of on mouse over or click for the template column image). For this purpose you can intercept the OnRowContextMenu client event of RadGrid and extract the index of the right-clicked item (through the eventArgs.get_itemIndexHierarchical() argument) or its primary key (see this demo for more info on the matter) to pass it to the radopen method.

I hope this solution is feasible for your case.

Best regards,
Stephen
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
ayush mohan
Top achievements
Rank 1
answered on 27 Oct 2009, 06:25 PM
Could you please let me know, how can i get the column values for the row on client side?
Tags
Grid
Asked by
KevinMc
Top achievements
Rank 1
Answers by
KevinMc
Top achievements
Rank 1
Sebastian
Telerik team
ayush mohan
Top achievements
Rank 1
Share this question
or