San
San

Reputation: 1104

How to disable contextmenu except in the grid of telerik FileExplorer?

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.

I'm using telerik ASP.NET AJAX contorl 2009 Q2.

Thanks in advance.

Upvotes: 1

Views: 2990

Answers (1)

lingvomir
lingvomir

Reputation: 2584

This piece of code should help - basically what you need to do is attach a handler to the menu showing event, check the target element (the element where you right-clicked) and if it is the grid area itself - disable the menu item.

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

Upvotes: 2

Related Questions