Disable the rename option

8 posts, 0 answers
  1. Samee Mir
    Samee Mir avatar
    26 posts
    Member since:
    Jan 2010

    Posted 11 Feb 2010 Link to this post

    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 
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 16 Feb 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jim
    Jim avatar
    42 posts
    Member since:
    Mar 2009

    Posted 22 Feb 2010 Link to this post

    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;
  5. Jim
    Jim avatar
    42 posts
    Member since:
    Mar 2009

    Posted 23 Feb 2010 Link to this post

    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++;  
                    }  
                }  
            } 
  6. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 25 Feb 2010 Link to this post

    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.
  7. Chris
    Chris avatar
    4 posts
    Member since:
    May 2008

    Posted 26 Mar 2010 Link to this post

    Delete Me - silly error Sorry.

  8. Shailesh
    Shailesh avatar
    3 posts
    Member since:
    Aug 2013

    Posted 16 Jun 2014 in reply to Fiko Link to this post

    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
  9. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Jun 2014 in reply to Shailesh Link to this post

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