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

How to show context menu for GridDataItem

1 Answer 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 2
Simon asked on 02 Dec 2008, 02:52 PM
Hi

I am wanting to show the context menu I get when I right click, when I also hit enter on a selected row. I have captured the ENTER keypress, but can't fire off the context menu.

I was trying:

function RadGrid1_OnKeyPress(sender, eventArgs)
{
     switch(eventArgs.get_keyCode()) 
     { 
          case 13: 

               var ctmProducts = $find('<%=ctmProducts.ClientID %>'); 
               ctmProducts.show(eventArgs); 

               eventArgs.set_cancel(true); 
               break; 
     }
}               

 

 


Any pointers / thoughts welcome

Cheers

Simon

 

 

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 02 Dec 2008, 03:20 PM
Hello Simon,

I recommend you examine the following online demo:
AJAX-enabled context menu

<script type="text/javascript" language="javascript"
    function KeyPress(sender, eventArgs) 
    { 
        var menu = $find("<%=RadMenu1.ClientID %>"); 
        var evt = eventArgs.get_domEvent(); 
 
        if (evt.target.tagName == "INPUT" || evt.target.tagName == "A"
        { 
            return
        } 
 
        var element = eventArgs.get_domEvent().target.parentNode.rowIndex + 2; 
 
        sender.get_masterTableView().selectItem(element, true); 
 
        menu.show(evt); 
 
        evt.cancelBubble = true
        evt.returnValue = false
 
        if (evt.stopPropagation) 
        { 
            evt.stopPropagation(); 
            evt.preventDefault(); 
        } 
    } 
</script> 

Let us know if have more questions.

Best regards,
Daniel
the Telerik team

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