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

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

5 Answers 267 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
sandhya
Top achievements
Rank 1
sandhya asked on 26 May 2011, 01:09 PM
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

5 Answers, 1 is accepted

Sort by
0
Mani Pandian
Top achievements
Rank 1
answered on 27 May 2011, 05:25 PM
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

 

 

 

 

 

0
juan
Top achievements
Rank 1
answered on 20 Jul 2011, 10:41 PM
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>
0
Mani Pandian
Top achievements
Rank 1
answered on 20 Jul 2011, 11:03 PM
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

0
Terri-Lynn
Top achievements
Rank 1
answered on 31 Oct 2011, 11:18 PM
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??
0
Dobromir
Telerik team
answered on 04 Nov 2011, 01:15 PM
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
Tags
FileExplorer
Asked by
sandhya
Top achievements
Rank 1
Answers by
Mani Pandian
Top achievements
Rank 1
juan
Top achievements
Rank 1
Terri-Lynn
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or