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

Disable Directory Deleting and Renaming

1 Answer 111 Views
Editor
This is a migrated thread and some comments may be shown as answers.
DogBizPro
Top achievements
Rank 1
DogBizPro asked on 03 Sep 2016, 02:13 PM
How do I disable the rename and delete options for the context menu for the Image Manager window? I see the info about using external dialogs, but how do I set that up when the ImageManager is being called from within the Editor?

1 Answer, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 05 Sep 2016, 07:15 AM
Hi,

There are two approaches that you can try and/or combine to achieve your scenario:

Approach 1) The permissions given to the Image Manager depend on the paths set to its ViewPaths, UploadPaths and DeletePaths properties.

For example, if you have the following folder structure:

      - Root
              - Folder1
              - Folder2

the configuration below will give all permissions to Folder1, view and delete permissions to Folder2 and only view permissions to the Root directory:
Copy Code
<telerik:RadEditor runat="server" ID="RadEditor1">
    <ImageManager ViewPaths="~/Root" DeletePaths="~/Root/Folder1, ~/Root/Folder2" UploadPaths="~/Root/Folder1"/>
</telerik:RadEditor>

Approach 2) If the above configuration is not enough, you can customize the FileBrowser dialog. You can read more about that here—http://demos.telerik.com/aspnet-ajax/editor/examples/externaldialogspath/defaultcs.aspx.

Further, once getting the FileBrowser.ascx file you can use the FileExplorer's OnClientLoad and OnClientMove events to change the desired UI elements:
Copy Code
<script>
    function OnClientLoad(sender, args) {
        // Remove rename option from grid's context menu
        var gridRenameCmd = sender.get_gridContextMenu().findItemByText("Rename");
        gridRenameCmd.set_visible(false);
 
        // Remove rename option from tree's context menu
        var treeRenameCmd = sender.get_tree().get_contextMenus()[0].findItemByText("Rename");
        treeRenameCmd.set_visible(false);
 
        // The same can be done for the delete option
    }
             //disable drag and drop
    function OnClientMove(sender, args) {
        args.set_cancel(true);
    }
</script>
 
...
 
<telerik:RadFileExplorer ID="RadFileExplorer1" Height="450px" Width="400px" TreePaneWidth="150px"
    runat="Server" EnableOpenFile="false" AllowPaging="true" PageSize="100" OnClientLoad="OnClientLoad" OnClientMove="OnClientMove"/>

You can find attached an example that illustrates the suggestion above.


Best regards,
Rumen
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Editor
Asked by
DogBizPro
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or