Events on the tree stops working after folder rename/move/delete/..

3 posts, 1 answers
  1. Andreas
    Andreas avatar
    12 posts
    Member since:
    Aug 2010

    Posted 05 Oct 2010 Link to this post

    When the file explorer is loaded I add handlers to intercept context menu handling for the tree view part (I enable/disable menu options). This is hooked up like this


    In a user control:

    <telerik:RadFileExplorer  ...  OnClientLoad="EXPLORER.attachHandlers" 


    the javascript:

    var EXPLORER =    {

            attachHandlers: function (explorer, args) {

                   var tree = explorer.get_tree();





    The functions treeContextMenuShowing and is now run every time I right click a folder  in the tree and treeContextMenuClicking  is run when I click a menu context menu item.


    However, those functions isn't called on user interaction anymore after I've done an "updating command", like renamed a folder or created a new folder via the context menu in the tree view. The events stops firing for all the folder nodes in the tree, not only the one(s) I've updated.


    I also has showing and click events hooked up for the grid context menu, and they keep working after I do updates to the items in the grid. So the problem is local to the tree.


    What do I do to fix this?

    Thank you,

    Best regards,

    Andreas Nilsson

  2. Answer
    Dobromir avatar
    1633 posts

    Posted 06 Oct 2010 Link to this post

    Hi Andreas,

    This is an expected behavior of RadFileExplorer. The refresh of the RadFileExplorer is an AJAX request, during this request the TreeView client-side object is recreated, thus all event handlers registered during the RadFileExplorer OnLoad event are lost. In order to avoid this issue you need to re-attach the custom handlers in the OnAjaxResponseEnd event of the UpdatePanel, e.g.:
    <telerik:RadFileExplorer ID="RadFileExplorer1" runat="server" OnClientLoad="OnClientLoad">
        <Configuration ViewPaths="~/ROOT" DeletePaths="~/ROOT" UploadPaths="~/ROOT" />
    <script type="text/javascript">
        function OnClientLoad(sender, args)
            var tree = sender.get_tree();
            tree.add_contextMenuShowing(function () { alert(1); });
            tree.add_contextMenuItemClicking(function () { alert(2); });
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function ()
            setTimeout(function ()
                var fileExplorer = $find("<%=RadFileExplorer1.ClientID%>");
                var tree = fileExplorer.get_tree();
                tree.add_contextMenuShowing(function () { alert(1); });
                tree.add_contextMenuItemClicking(function () { alert(2); });
            }, 0);

    I hope this helps.

    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft R3 2016 release webinar banner
  4. Andreas
    Andreas avatar
    12 posts
    Member since:
    Aug 2010

    Posted 15 Oct 2010 Link to this post

    Thank you Dobomir, it worked.

    However, I find it a bit odd that it is considered "standard behavior" that the tree view is recreated. The grid is also seemingly reloaded with data, but it manages to keep its events. It is not that obvious that the tree view is recreated, but the grid is not.
Back to Top