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

Grid item?

1 Answer 36 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saad
Top achievements
Rank 1
Saad asked on 08 Dec 2008, 05:48 AM
I want to put a invisible menu named 'options' on each row of my grid. When user brings mouse over that, it should get visible and gets invisible again on mouseOut. And a small menu drops out by click that 'option'. How to do that using javascript and how to know that what option has been selected at client side?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Dec 2008, 08:42 AM
Hi Saadi,

Subscribe for OnRowMouseOver="ContextMenuShow" for the clientevents of RadGrid in order to show the context menu. Then check which item is clicked in onclicentclick event of RadContextMenu. You can try following code snippet to achieve the desired scenario.

ASPX:
<telerik:RadContextMenu ID="RadMenu1" runat="server" Skin="Vista" onclientitemclicked="ItemClicked">  
    <Items> 
          <telerik:RadMenuItem Text="Options" > 
          <Items> 
                <telerik:RadMenuItem runat="server" Text="Option 1" Value="1">  
                </telerik:RadMenuItem> 
                <telerik:RadMenuItem runat="server" Text="Option 2" Value="2">  
                </telerik:RadMenuItem> 
          </Items> 
          </telerik:RadMenuItem> 
    </Items> 
</telerik:RadContextMenu> 

JavaScript:
<script type="text/javascript">  
function ContextMenuShow(sender, eventArgs)  
{  
    var menu = $find("<%=RadMenu1.ClientID %>");  
    var evt = eventArgs.get_domEvent();  
    menu.show(evt);  
}  
function ItemClicked(sender, eventArgs)  
{  
    var menu = $find("<%=RadMenu1.ClientID %>");  
    var temp= eventArgs.get_item().get_value();  
    if (temp==1)  
        alert("Clicked Option 1");  
    else 
        alert("Clicked Option 2");  
}  
</script> 


Thanks,
Princy.
Tags
Grid
Asked by
Saad
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or