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

Disabling context menu items and upload buttons

2 Answers 181 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 2
Joe asked on 06 Sep 2011, 09:32 PM
I need to disable a certain context menu item (upload) and disable the upload button from the toolbar. 

I found this code to disable the toolbar upload function (and it works)

           Dim toolBar As RadToolBar = RadFileExplorer1.ToolBar
           ' Remove commands from the ToolBar control; 
           Dim i As Integer = 0
           While i < toolBar.Items.Count
               If toolBar.Items(i).Value = "Delete" Then
                   toolBar.Items.RemoveAt(i)
                   ' Next item 
                   Continue While
 
               ElseIf toolBar.Items(i).Value = "Upload" Then
                   toolBar.Items.RemoveAt(i)
                   ' Next item 
                   Continue While
               End If
 
               ' Next item 
               i += 1
           End While

Is there similar code to disable the context menu item (upload) in the code behind? I want to control this based on user login as I will use an IF statement to check the login name.

Thanks,
Joe

2 Answers, 1 is accepted

Sort by
0
Accepted
Dobromir
Telerik team
answered on 07 Sep 2011, 11:30 AM
Hi Joe,

By design, RadFileExplorer enables the upload functionality if the current selected folder (or its parent folder(s)) is listed in the UploadPaths property. If upload permissions is not provided for the specific folder the Upload button on the toolbar and the context menu items will not be rendered at all.

The recommended approach to disable Upload button and context menus according to the logged user is to modify the UploadPaths property.

If you need to manually remove the context menu items you can use the following code:
Dim treeViewContextMenu As RadContextMenu = fileExplorer.TreeView.ContextMenus(0)
       ' Remove commands from the TreeView's ContextMenus control;
       i = 0
       While i < treeViewContextMenu.Items.Count
           If treeViewContextMenu.Items(i).Value = "Delete" Then
               treeViewContextMenu.Items.RemoveAt(i)
               ' Next item
               Continue While
 
           ElseIf treeViewContextMenu.Items(i).Value = "Upload" Then
               treeViewContextMenu.Items.RemoveAt(i)
               ' Next item
               Continue While
           End If
 
           ' Next item
           i += 1
       End While
 
 
 
       Dim gridContextMenu As RadContextMenu = fileExplorer.GridContextMenu
       ' Remove commands from the GridContextMenu control;
 
       i = 0
       While i < gridContextMenu.Items.Count
           If gridContextMenu.Items(i).Value = "Delete" Then
               gridContextMenu.Items.RemoveAt(i)
               ' Next item
               Continue While
 
           ElseIf gridContextMenu.Items(i).Value = "Upload" Then
               gridContextMenu.Items.RemoveAt(i)
               ' Next item
               Continue While
           End If
 
           ' Next item
           i += 1
       End While

A example of how to manually disable Delete and Upload commands is available in the following KB article:
Remove the "Delete" and "Upload" commands from the RadFileExplorer control


Kind regards,
Dobromir
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Joe
Top achievements
Rank 2
answered on 07 Sep 2011, 04:12 PM
Thanks! Just what I needed....

Joe
Tags
FileExplorer
Asked by
Joe
Top achievements
Rank 2
Answers by
Dobromir
Telerik team
Joe
Top achievements
Rank 2
Share this question
or