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

Disable the rename option

7 Answers 189 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Samee Mir
Top achievements
Rank 1
Samee Mir asked on 11 Feb 2010, 09:55 AM
hi,

  if i want to disable the option of rename how can i do it??means when the user right clicks the file the rename option should be disable.........how can i do it??secondly if i want to disable the rename option on directory which starts with name shortcuts how can i do it??

regards

samee javaid 

7 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 16 Feb 2010, 04:05 PM
Hello Samee,

You need to attach two client-side handlers as shown bellow:
protected void Page_Load(object sender, EventArgs e)
{
    RadFileExplorer1.TreeView.OnClientContextMenuShown = "OnTreeContextMenuShown";
    RadFileExplorer1.GridContextMenu.OnClientShown = "OnGridClientShown";
}

Then implement the desired logic in the attached handler. For your convenience I have attached a fully working demo to this threads that shown the basic steps in order to achieve the desired result.

I hope this helps.

Regards,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jim
Top achievements
Rank 1
answered on 23 Feb 2010, 12:58 AM
did anybody have any luck with this? I tried the example, and it didn't do anything for me. In addition, what a bunch of work to perform such a simple action. How about rename.visible = false;
0
Jim
Top achievements
Rank 1
answered on 23 Feb 2010, 07:29 PM
I found the following elsewhere on the forum:
        private void ConfigureFileExplorer(RadFileExplorer fileExplorer, bool bIsReadOnly, string sFilePaths)  
        {  
            string[] aFilePath = sFilePaths.Split(',');  
            fileExplorer.InitialPath = Page.ResolveUrl(aFilePath[0]);  
            fileExplorer.Configuration.ViewPaths = aFilePath;  
            fileExplorer.Configuration.UploadPaths = aFilePath;  
            fileExplorer.Configuration.DeletePaths = aFilePath;  
 
            if (!bIsReadOnly)  
            {  
                fileExplorer.EnableOpenFile = true;  
                fileExplorer.DisplayUpFolderItem = false;  
                fileExplorer.EnableCreateNewFolder = false;  
                fileExplorer.AllowPaging = false;  
                fileExplorer.VisibleControls = GetVisibleControls();  
 
                RadToolBar toolBar = fileExplorer.ToolBar;  
                int i = 0;  
 
                while (i < toolBar.Items.Count)  
                {  
                    if (toolBar.Items[i].Value == "Rename")  
                    {  
                        toolBar.Items.RemoveAt(i);  
                        continue;  
                    }  
 
                    i++;  
                }  
 
                RadContextMenu treeViewContextMenu = fileExplorer.TreeView.ContextMenus[0];  
                i = 0;  
                while (i < treeViewContextMenu.Items.Count)  
                {  
                    if (treeViewContextMenu.Items[i].Value == "Rename")  
                    {  
                        treeViewContextMenu.Items.RemoveAt(i);  
                        continue;  
                    }  
                    i++;  
                }  
 
                RadContextMenu gridContextMenu = fileExplorer.GridContextMenu;  
                i = 0;  
                while (i < gridContextMenu.Items.Count)  
                {  
                    if (gridContextMenu.Items[i].Value == "Rename")  
                    {  
                        gridContextMenu.Items.RemoveAt(i);  
                        continue;  
                    }  
                    i++;  
                }  
            }  
            else  
            {  
                fileExplorer.TreeView.EnableDragAndDrop = false;  
                fileExplorer.Grid.ClientSettings.AllowRowsDragDrop = false;  
 
                fileExplorer.DisplayUpFolderItem = false;  
                fileExplorer.EnableCreateNewFolder = false;  
                fileExplorer.AllowPaging = false;  
 
                RadToolBar toolBar = fileExplorer.ToolBar;  
                int i = 0;  
                  
                while (i < toolBar.Items.Count)  
                {  
                    if (toolBar.Items[i].Value == "Delete" || toolBar.Items[i].Value == "Upload" || toolBar.Items[i].Value == "Rename")  
                    {  
                        toolBar.Items.RemoveAt(i);  
                        continue;  
                    }  
 
                    i++;  
                }  
 
                RadContextMenu treeViewContextMenu = fileExplorer.TreeView.ContextMenus[0];  
                i = 0;  
                while (i < treeViewContextMenu.Items.Count)  
                {  
                    if (treeViewContextMenu.Items[i].Value == "Delete" || treeViewContextMenu.Items[i].Value == "Upload" || treeViewContextMenu.Items[i].Value == "Rename")  
                    {  
                        treeViewContextMenu.Items.RemoveAt(i);  
                        continue;  
                    }  
                    i++;  
                }  
 
                RadContextMenu gridContextMenu = fileExplorer.GridContextMenu;  
                i = 0;  
                while (i < gridContextMenu.Items.Count)  
                {  
                    if (gridContextMenu.Items[i].Value == "Delete" || gridContextMenu.Items[i].Value == "Upload" || gridContextMenu.Items[i].Value == "Rename")  
                    {  
                        gridContextMenu.Items.RemoveAt(i);  
                        continue;  
                    }  
                    i++;  
                }  
            }  
        } 
0
Fiko
Telerik team
answered on 25 Feb 2010, 10:50 AM
Hi Jim,

The approach you post here is described in this KB article. Please note that this code will completely disable the Rename command. The attached project to this thread, however, disables the rename option only for directories - it is enabled for files. The purpose of the attached example (to my first reply to this thread) is to show how to disable Rename command on the client. You can implement your logic that will determine whether the rename option is allowed in the current context and use the provided code in order to disable the Rename option in the shown context menu.

Regards,
Fiko
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Chris
Top achievements
Rank 1
answered on 26 Mar 2010, 07:12 PM

Delete Me - silly error Sorry.

0
Shailesh
Top achievements
Rank 1
answered on 16 Jun 2014, 11:47 AM
Hi Fiko,
I am trying to disable with solution you have given here but how to refer RadFileExplorer in our present code and where to do it.

Can you please add here more clear answer.



Regards
Shailesh Naik
0
Princy
Top achievements
Rank 2
answered on 17 Jun 2014, 06:03 AM
Hi Shailesh,

Please try the below sample code snippet to achieve your scenario.

ASPX:
<telerik:RadFileExplorer ID="rfileexplorerDisableRename" runat="server">
    <Configuration ViewPaths="~/RadAsyncUpload/Uploads/" UploadPaths="~/RadAsyncUpload/Uploads/"
        DeletePaths="~/RadAsyncUpload/Uploads/" EnableAsyncUpload="true" />
</telerik:RadFileExplorer>

C#:
protected void Page_Load(object sender, EventArgs e)
{
    //attaching event for the contextmenu
    rfileexplorerDisableRename.GridContextMenu.OnClientShown = "showContextmenu";
}

JavaScript:
function showContextmenu(sender, args) {
    var gridContextMenuItems = sender.get_allItems();
    var menuItem;
    for (var i = 0; i < gridContextMenuItems.length; i++) {
        menuItem = gridContextMenuItems[i];
        if (menuItem.get_value() == "Rename") {
            menuItem.disable(); // Disable the rename function
        }
    }
}

Thanks,
Princy.
Tags
FileExplorer
Asked by
Samee Mir
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Jim
Top achievements
Rank 1
Chris
Top achievements
Rank 1
Shailesh
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or