How to disable rename functionality for root node in RAD File explorer

6 posts, 0 answers
  1. sandhya
    sandhya avatar
    12 posts
    Member since:
    May 2011

    Posted 26 May 2011 Link to this post

    Hi,

    Please can u help me how to disable the rename functionality for treeview root node in RAD File explorer.
    By default Delete functionality will disable for root node while right clicking on context menu treeview in file explorer .same thng it should happen for reanme.other than root node it should enable rename functionality
    Please can u help me out..
    How to solve this?
    and one more thing how to get root node text on client side.

    Thanks\
    Bhavani
  2. Mani Pandian
    Mani Pandian avatar
    3 posts
    Member since:
    Dec 2009

    Posted 27 May 2011 Link to this post

    Hi,

    For this to happen you can use the  OnClientContextMenuShown client function  by setting the

    radFileExplorer.TreeView.OnClientContextMenuShown ="OnClientContextMenuShown" on serevr side logic

     

     

     

    Client Script :

    function OnClientContextMenuShown(oTreeView, args) {
    var pathToItem = args.get_node().get_value();
    var treeContextMenuItems = args.get_menu().get_allItems();
    if (pathToItem == "/Root/") {
    for (var i = 0; i < treeContextMenuItems.length; i++) {
    var menuItem = treeContextMenuItems[i];
    if (menuItem.get_value() == "Rename" || menuItem.get_value() == "Copy") {
    menuItem.set_enabled(false);
    }
    }
    }
    }


    Note : Replace the string  "/Root/" with your root folder name and the args.get_node().get_value();
    will fetch you the name of the current selected node.

     

    Hope this helps

    Mani

     

     

     

     

     

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. juan
    juan avatar
    3 posts
    Member since:
    Oct 2007

    Posted 20 Jul 2011 Link to this post

    but now if i want to not visible in the GridContextMenu?

    i have this code but is wrong.

    RadFileExplorer1.GridContextMenu.OnClientShown = "EliminarOpcionesEnMenu"

    <script type="text/javascript">
            function EliminarOpcionesEnMenu(oTreeView, args) {
                var pathToItem = args.get_node().get_value();
                var treeContextMenuItems = args.get_menu().get_allItems();
              
                    for (var i = 0; i < treeContextMenuItems.length; i++) {
                        var menuItem = treeContextMenuItems[i];
                        if (menuItem.get_value() == "Rename" || menuItem.get_value() == "Copy") {
                           menuItem.set_visible(false);
                        }
                    }
              
            }
         </script>
  5. Mani Pandian
    Mani Pandian avatar
    3 posts
    Member since:
    Dec 2009

    Posted 20 Jul 2011 Link to this post

    Try this out

    RadFileExplorer1.GridContextMenu.OnClientShown = "EliminarOpcionesEnMenu"
     
    < script type="text/javascript">
     function EliminarOpcionesEnMenu(oTreeView, args) {
     var pathToItem = args.get_node().get_value();
     var treeContextMenuItems = args.get_menu().get_allItems();
      
    for (var i = 0; i < treeContextMenuItems.length; i++) {
     var menuItem = treeContextMenuItems[i];
     if (menuItem.get_value() == "Rename" || menuItem.get_value() == "Copy") {
     menuItem.style.diplay ="none";
     }
     }
     
    }
    < /script>  


    Reference :
    http://www.telerik.com/community/forums/aspnet-ajax/grid/remove-options-from-radgrid-header-context-menu.aspx

  6. Terri-Lynn
    Terri-Lynn avatar
    45 posts
    Member since:
    Dec 2010

    Posted 31 Oct 2011 Link to this post

    Hi all:
    This solution is almost exactly what I want, BUT, I want to pass to the function which folders specificially.  I don't want to hard code it in like the above solution ("/Root/").  Any further ideas??
  7. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 04 Nov 2011 Link to this post

    Hi Terri-Lynn,

    I am not quite sure I understand the exact scenario. The modifications discussed in this thread are regarding hiding the Rename for the root (top level) folder set to RadFileExplorer. If you need to apply this modification for multiple scenarios (or in a scenario where the root folder can be changed dynamically) you can use the following approach to dynamically access the path of the root node:
    function OnClientContextMenuShown(oTreeView, args)
    {
        var pathToItem = args.get_node().get_value();
        var rootNodes = oTreeView.get_nodes();
     
        var rootPaths = [];
        for (var i = 0; i < rootNodes.get_count(); i++) {
            rootPaths.push(rootNodes.getNode(i).get_value());
        }
     
        var treeContextMenuItems = args.get_menu().get_allItems();
        if (rootNodes.indexOf(pathToItem) > -1) {
            for (var i = 0; i < treeContextMenuItems.length; i++) {
                var menuItem = treeContextMenuItems[i];
                if (menuItem.get_value() == "Rename" || menuItem.get_value() == "Copy") {
                    menuItem.set_enabled(false);
                }
            }
        }
    }

    I hope this helps.

    Kind regards,
    Dobromir
    the Telerik team
    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 their blog feed now
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017