RadFileExplorer

2 posts, 0 answers
  1. kalai
    kalai avatar
    1 posts
    Member since:
    Oct 2013

    Posted 24 Oct 2013 Link to this post

    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
     
  2. Vessy
    Admin
    Vessy avatar
    1389 posts

    Posted 29 Oct 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top