Tree View events not firing after explorer refresh

4 posts, 0 answers
  1. friendz 4u
    friendz 4u avatar
    4 posts
    Member since:
    Mar 2010

    Posted 01 Apr 2010 Link to this post

    I have some events attached on the tree view using the following code.
     function OnClientLoad(explorer, args) { 
            var tree = explorer.get_tree(); 

    initially those event handlers are being called but after  refreshing the explorer using fileExp.refresh(); or using toolbar refresh icon those events are not being called. I have tried to reattached those event after explorer refresh but it didn't solve the problem.
  2. Lini
    Lini avatar
    2144 posts

    Posted 02 Apr 2010 Link to this post


    This problem happens because the tree control is recreated from the server when you make an ajax request from the file explorer control (e.g. refresh, create folder, delete file, etc.). Your events are attached to the original tree control, which is destroyed and created again after the ajax call. To workaround this, you need to add a handler for the RadFileExplorer's ajaxRequestEnd client event and re-attach the handlers there as well. Here is the updated code:

    function attachTreeHandlers(tree)
    function OnClientLoad(explorer, args) {
        var tree = explorer.get_tree();

    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. James
    James avatar
    8 posts
    Member since:
    Nov 2010

    Posted 10 Feb 2011 Link to this post

    I am having the exact same problem, i have created a number of custom buttons and items to add to both the context menus of the tree and grid however after a refresh of the file explorer, either through re naming/deleting an item none of these custom buttons fire the events. I have tried adding the handlers back in using the example above but the tree view is attached server side and i havent been able to find any documentation on on here about accessing the trees context menu to attempt to attach it client side. below is the code im currently using:

    <telerik:RadFileExplorer ID="rfeFilesAndFolders" runat="server" Height="300px" 
        width="920px" Skin="Office2007" OnClientFileOpen="fileOpen" 
        EnableOpenFile="true" OnClientLoad="attachHandlers" 
        OnClientFolderChange="OnClientFolderChange" AllowPaging="true" PageSize="8" >

    function attachHandlers(explorer, args) {
           explorer.add_ajaxRequestEnd(function () { setuphandlers(explorer); });
       function setuphandlers(explorer) {
           //support for grid context menu
           var toolbar = explorer.get_toolbar();
           //support for grid context menu
           var gridContextMenu = explorer.get_gridContextMenu();
           //TreeView handler is attached in codebehind
           var fileExplorer = $find("<% = rfeFilesAndFolders.ClientID %>");
           //Disable toolbar buttons
           var toolbar = fileExplorer.get_toolbar();
           var button = toolbar.findItemByValue("Add Note");
           button = toolbar.findItemByValue("View Notes");
           button = toolbar.findItemByValue("View Ratings");
           button = toolbar.findItemByValue("Share");

    and an example of the server side code for adding one of these custom buttons

    Private Sub AddUploadButton()
            'custom button
            Dim customButton As New RadToolBarButton("Upload Documents")
            customButton.CssClass = "icnUpload rtbWrap"
            customButton.Value = "uploaddocuments"
            'context menu item
            Dim customMenuOption As New RadMenuItem("Upload Documents")
            customMenuOption.Value = "uploaddocuments"
            'attach the event handler to the RadTreeView
            rfeFilesAndFolders.TreeView.OnClientContextMenuItemClicked = "treeContextMenuClicked"
            'if you want the custom context menu item to be visible in the grid as well
        End Sub

    hope you can help, its been driving me crazy!

  5. Dobromir
    Dobromir avatar
    1633 posts

    Posted 15 Feb 2011 Link to this post

    Hi James,

    The provided sample code looks OK. And since you are attaching the context menu handler in the code behind you should not experience this behavior:
    rfeFilesAndFolders.TreeView.OnClientContextMenuItemClicked = "treeContextMenuClicked"

    Could you please provide runnable sample project reproducing the problem so we can investigate it further?

    Kind regards,
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Back to Top