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

Tree View events not firing after explorer refresh

3 Answers 96 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
friendz 4u
Top achievements
Rank 1
friendz 4u asked on 01 Apr 2010, 10:10 AM
Hi,
I have some events attached on the tree view using the following code.
 function OnClientLoad(explorer, args) { 
 
        var tree = explorer.get_tree(); 
 
        tree.add_nodeEditing(OnClientTreeNodeEditing); 
        tree.add_contextMenuShowing(TreeContextMenuShowing); 
    }   

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.
thanks
Arpan

3 Answers, 1 is accepted

Sort by
0
Lini
Telerik team
answered on 02 Apr 2010, 01:44 PM
Hello,

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)
{
    tree.add_nodeEditing(OnClientTreeNodeEditing);
    tree.add_contextMenuShowing(TreeContextMenuShowing);
}
function OnClientLoad(explorer, args) {
 
    var tree = explorer.get_tree();
    attachTreeHandlers(tree);
    explorer.add_ajaxRequestEnd(function(){attachTreeHandlers(tree);});
}


Greetings,
Lini
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.
0
James
Top achievements
Rank 1
answered on 10 Feb 2011, 11:34 AM

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" 
    OnExplorerPopulated="rfeFilesAndFolders_ExplorerPopulated" 
    OnClientFolderChange="OnClientFolderChange" AllowPaging="true" PageSize="8" >
  
</telerik:RadFileExplorer>

function attachHandlers(explorer, args) {
       setuphandlers(explorer);
       explorer.add_ajaxRequestEnd(function () { setuphandlers(explorer); });
         
   }
   function setuphandlers(explorer) {
       //support for grid context menu
       var toolbar = explorer.get_toolbar();
       toolbar.add_buttonClicked(toolbarClicked);
       //support for grid context menu
       var gridContextMenu = explorer.get_gridContextMenu();
       gridContextMenu.add_itemClicked(gridContextMenuClicked);
       //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.disable();
       button = toolbar.findItemByValue("View Notes");
       button.disable();
       button = toolbar.findItemByValue("View Ratings");
       button.disable();
       button = toolbar.findItemByValue("Share");
       button.disable();
   }

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"
        rfeFilesAndFolders.ToolBar.Items.Add(customButton)
        'context menu item
        Dim customMenuOption As New RadMenuItem("Upload Documents")
        customMenuOption.Value = "uploaddocuments"
        rfeFilesAndFolders.TreeView.ContextMenus(0).Items.Add(customMenuOption)
  
        '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
        rfeFilesAndFolders.GridContextMenu.Items.Add(customMenuOption.Clone())
  
    End Sub

hope you can help, its been driving me crazy!

James
0
Dobromir
Telerik team
answered on 15 Feb 2011, 12:19 PM
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,
Dobromir
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.
Tags
FileExplorer
Asked by
friendz 4u
Top achievements
Rank 1
Answers by
Lini
Telerik team
James
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or