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

RadFileExplorer

1 Answer 44 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
kalai
Top achievements
Rank 1
kalai asked on 24 Oct 2013, 01:57 PM
RadFileExplorer:remove the delete and rename option for particular folder

i have one root node name :myfile
    subfolder:PrivateFolder


i want remove the delete and rename option for this private folder only how to achieve this

code :
private void RemoveUploadAndDelete(RadFileExplorer fileExplorer)
    {
        int i;// Global variable for that function


        RadToolBar toolBar = fileExplorer.ToolBar;
        // Remove commands from the ToolBar control;
        i = 0;
        while (i < toolBar.Items.Count)
        {
            if (toolBar.Items[i].Value == "Delete")
            {
                toolBar.Items.RemoveAt(i);
                continue;// Next item
            }

            else if (toolBar.Items[i].Value == "Rename")
            {
                toolBar.Items.RemoveAt(i);
                continue; // Next item
            }

            i++;// Next item
        }

        RadContextMenu treeViewContextMenu = 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")
            {
                treeViewContextMenu.Items.RemoveAt(i);
                continue;// Next item
            }

            else if (treeViewContextMenu.Items[i].Value == "Rename")
            {
                treeViewContextMenu.Items.RemoveAt(i);
                continue;// Next item
            }

            i++;// Next item
        }


        RadContextMenu gridContextMenu = fileExplorer.GridContextMenu;
        // Remove commands from the GridContextMenu control;

        i = 0;
        while (i < gridContextMenu.Items.Count)
        {
            if (gridContextMenu.Items[i].Value == "Delete")
            {
                gridContextMenu.Items.RemoveAt(i);
                continue;// Next item
            }

            else if (gridContextMenu.Items[i].Value == "Rename")
            {
                gridContextMenu.Items.RemoveAt(i);
                continue;// Next item
            }

            i++;// Next item
        }
    }


But it remove the option all the folder.i want remove the delete and rename option private folder only
 

1 Answer, 1 is accepted

Sort by
0
Vessy
Telerik team
answered on 29 Oct 2013, 08:16 AM
Hi Kalai,

RadFileExplorer does not provide such functionality out of the box, but you can customize it in order to achieve a similar behavior. What you should do is:
  • Subclass the built in FileSystemContentProvider
  • Override its the ResolveDirectory() and ResolveRootDirectoryAsTree() methods in roder to modify the folder/files permissions in the PrivateFolder and all of its subfolders. For example:
public override DirectoryItem ResolveDirectory(string path)
{
    var baseDir = base.ResolveDirectory(path);
 
    foreach (var file in baseDir.Files)
    {
        if (file.Path.Contains("myfile/PrivateFolder"))
            file.Permissions = PathPermissions.Read;
    }
    return baseDir;
}
 
public override DirectoryItem ResolveRootDirectoryAsTree(string path)
{
    var baseDir = base.ResolveRootDirectoryAsTree(path);
 
    foreach (var dir in baseDir.Directories)
    {
        if (dir.FullPath.Contains("myfile/PrivateFolder"))
            dir.Permissions = PathPermissions.Read;
    }
    return baseDir;
}

I hope this helps.

Regards,
Veselina Raykova
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
FileExplorer
Asked by
kalai
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Share this question
or