How to disable contextmenu except in the grid row?

3 posts, 0 answers
  1. Tom
    Tom avatar
    13 posts
    Member since:
    Jul 2012

    Posted 23 Jul 2009 Link to this post

    I tried to disable unnecessary context menu when I set a grid with ContextMenus. By default, if you click the blank part of the grid, it disables the Delete menu.

    However, after adding customized menu like Download, it shows in the context menu even there is no selected item (i.e., How can I download it?). So I want to disable the unnecessary menu or make it invisible except in the grid row context menu.

  2. Tom
    Tom avatar
    13 posts
    Member since:
    Jul 2012

    Posted 24 Jul 2009 Link to this post

    I solved the problem partially using the fllowing codes from

    <script type="text/javascript">
    function OnClientLoad(explorer)
    function disableItem(sender, args)
    var target = args.get_targetElement();
    if (target && target.className == "rgDataDiv")
    var dlItem = sender.findItemByValue("download");
    telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" OnClientLoad="OnClientLoad"></telerik:RadFileExplorer>

    However, I still have an enabled menu in the header context menu. What is the working className or soultion for Header Context Menu?
  3. Lini
    Lini avatar
    2150 posts

    Posted 27 Jul 2009 Link to this post


    The solution you have is almost complete. You just need to handle more specific cases in the disableItem() function.

    function disableItem(sender, args) 
        var target = args.get_targetElement(); 
        var isOverRow = false
        if (target) 
            if (Sys.UI.DomElement.containsCssClass(target, "rfeFileExtension") ||  
                (target.tagName.toLowerCase() == "td" && !target.className)) 
                isOverRow = true
        if (!isOverRow) 
            //disable new item 
            var dlItem = sender.findItemByValue("download"); 

    Here is the updated code. It checks only if the click was over a grid row. Everywhere else it will disable the custom menu item.

    Kind regards,
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top