You could implement the following code in order to show the desired messages :
Attach the handlers to the OnClientDelete and OnClientMove events
You could implement two functions that will help you in the next steps :
- isRootDir(oTree, path) - checks whether the path parameter is the path to the root directory. The oTree is the embedded into RadFileExplorer control RadTreeView client object.
- isRenaming(destPath) - This function is used inside the OnClientMove
handler and returns whether the destPath does not contain '/' symbol.
This mean that the current operation is rename one, not move.
The delete handler's implementation as follow :
function OnClientDelete(oExplorer, args)
{
var isRoot = isRootDir(oExplorer.get_tree(), args.get_path());
// Check whether the moved item is a directorty and whether it is the root directory;
if (args.get_item().isDirectory() && isRoot)
{
alert("You cannot delete the root directory");
args.set_cancel(true);
}
}
The move handler's declaration :
function OnClientMove(oExplorer, args)
{
var isRoot = isRootDir(oExplorer.get_tree(), args.get_path());
// Check whether the moved item is a directorty and whether it is the root directory;
if (args.get_item().isDirectory() && isRoot)
{
// Check whether this is a renaming ;
if (isRenaming(args.get_newPath()))
{// The renaming operation ;
alert("You cannot rename the root directory");
args.set_cancel(true);
}
}
}
I
tested the OnClientDelete event but I was not able to reproduce the
issue. The event is fired before the physical delete operation and it can
be canceled as well.
For your convenience I have implemented the above described steps in a
demo and attached it to the thread. Additionally, I saw that you use an
older version of the control and I strongly recommend you upgrade to
the newest one - 2009.2.701. This version is a fully backward
compatible with the version that you use and you should not have any problems with the update.