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

How do I : show alert message when user try to rename and delete root directory

1 Answer 106 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Amol
Top achievements
Rank 2
Amol asked on 28 Jul 2009, 10:06 AM
Hello,

Is it possible to show alert message when user try to rename and delete root directory?
Currently it does not show any messages to user.

Also,
OnClientDelete event calls after deleting item, Is it possible to call it before deleting item?


Thanks,
Amol



1 Answer, 1 is accepted

Sort by
0
Accepted
Fiko
Telerik team
answered on 30 Jul 2009, 09:54 AM
Hello Amol,

In reference to your questions :

  • 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.

I hope this helps.


All the best,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
FileExplorer
Asked by
Amol
Top achievements
Rank 2
Answers by
Fiko
Telerik team
Share this question
or