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

2 posts, 1 answers
  1. Amol
    Amol avatar
    57 posts
    Member since:
    Apr 2008

    Posted 28 Jul 2009 Link to this post

    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



  2. Answer
    Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 30 Jul 2009 Link to this post

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