Ajax events not triggered by FileExplorer

7 posts, 1 answers
  1. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 22 Apr 2009 Link to this post

    Hi,

    first of all my problem.
    I want to use RadFileExplorer to select directories. And I want to get a notification on server that a new folder got selected.
    And further assume that I only show the Treeview - else I have no problems at all - I simply use OnFolderLoaded which works.
    But when using only the treeview there is no OnFolderLoaded - BUT OnClientFolderChange fires in that situation.
    So from a first point of view it looks as if I got what I need.

    I handle my OnClientFolderChange like this:
    function OnClientFolderChange(sender, args) {  

    var

     

    item = args.get_item();

     

       TellServerAboutSelectedElement("DIR:" + item.get_path());  
    }  
     
    function TellServerAboutSelectedElement(argument) {  
        var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");  
        ajaxManager.ajaxRequest(argument);  
    So far so good - it does what I like - in some situations!!

    When the FileExplorer has to load something (the selected folder contains sub-folders) this call breaks the FileExplorer.
    I get a "never ending" loading animation.
    So I guess that my ajax call interferes with the ajax call the FileExplorer makes.

    Not that big problem - I only have to queue my call if the FileExplorer already is in an ajax call.
    So the idea is like this:
    function OnClientFolderChange(sender, args) {  
        var item = args.get_item();  
        if(nQueueCounter>0) {  
            EnqueuRequest("TellServerAboutSelectedElement""DIR:" + item.getPath();  
            return;  
            }  
        TellServerAboutSelectedElement("DIR:" + item.get_path());  
    }  
     
    function ResponseEnded(sender, args) {  
        nQueueCounter--;  
        HandleQueuedCalls();  
    }  
    function RequestStarted(sender, args) {  
        nQueueCounter++;  
    }  
     
    function TellServerAboutSelectedElement(argument) {  
        var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");  
        ajaxManager.ajaxRequest(argument);  
    }  
     
    This looks good - and the approach works (for an example) with a grid.
    BUT - neither OnRequestStart nor OnResponseEnd is fired when RadFileExplorer makes ajax calls.

    So it looks as if the RadFileExplorer bypasses RadAjaxManager - or doesn't handle it properly.
    I never ran in such a situation - so I don't know if RadAjax generally requires "no concurrency handling" or if this is only the fact with RadFileExplorer.
    Anyhow - with RadFileExplorer I need to synchronize my calls and the ones of the explorer - and this seems to be a problem since the needed events (requeststart - responseend) do not fire.

    Could someone pleas give me any advice?

    Regards

    Manfred
  2. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 22 Apr 2009 Link to this post

    Follow up -- I know (what's in documentation) about http://www.telerik.com/help/aspnet-ajax/ajxrequestqueuesize.html - but setting the size does not change anything!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Lini
    Admin
    Lini avatar
    2144 posts

    Posted 27 Apr 2009 Link to this post

    Hi,

    You can use the tree's "nodePopulating" and "nodePopulated" events to check if the tree is currently making an ajax request. I think the problem is that the tree uses a simple page callback request instead of a ASP.NET AJAX request. This is done to minimize the traffic between the server and the browser when populating nodes on demand. Here is the updated code:

    <script type="text/javascript"
    var queue = []; 
    var nQueueCounter =0; 
    function OnClientLoad(explorer) 
        var tree = explorer.get_tree(); 
        tree.add_nodePopulating(RequestStarted); 
        tree.add_nodePopulated(ResponseEnded); 
    function OnClientFolderChange(sender, args) {   
        var item = args.get_item();   
        if(nQueueCounter>0) {   
            EnqueuRequest("TellServerAboutSelectedElement""DIR:" + item.getPath());   
            return;   
            }   
        TellServerAboutSelectedElement("DIR:" + item.get_path());   
    }   
      
    function ResponseEnded(sender, args) {   
        nQueueCounter--;   
        HandleQueuedCalls();   
    function EnqueuRequest(what, argument) 
    queue[queue.length] = argument; 
    function HandleQueuedCalls() 
    for (var i=0;i++;i<queue.length) 
    TellServerAboutSelectedElement(queue[i]); 
    queue=[]; 
     
    function RequestStarted(sender, args) {   
        nQueueCounter++;   
    }   
      
    function TellServerAboutSelectedElement(argument) {   
        var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");   
        ajaxManager.ajaxRequest(argument);   
    }   
    </script> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"></telerik:RadAjaxManager> 
    <telerik:RadFileExplorer runat="server" ID="RadFileExplorer1" VisibleControls="TreeView" OnClientFolderChange="OnClientFolderChange" OnClientLoad="OnClientLoad"
            <Configuration ViewPaths="~/" DeletePaths="~/" UploadPaths="~/" /> 
    </telerik:RadFileExplorer> 

    I hope it helps.

    Kind regards,
    Lini
    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.
  5. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 27 Apr 2009 Link to this post

    Hi Lini,

    great solution - and queuing already implemented :)

    Thanks a lot for the (as usual with telerik) perfect support

    Manfred
  6. Tervel
    Admin
    Tervel avatar
    1337 posts

    Posted 27 Apr 2009 Link to this post

    Hello ManniAT,

    Now that we've helped you it will be great if you could pack this approach in (another) code library submission and share it with the rest of the Telerik community :)

    Best regards,
    Tervel
    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.
  7. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 27 Apr 2009 Link to this post

    Hi Tervel,

    I'll do this if you want - I just have to think about some extensions - a "fixed by telerik solution update" is not worth to be posted :)
    So expect the submisson at the end of this week or so.

    Regards

    Manfred
  8. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 27 Apr 2009 Link to this post

    An extra note Tervel,

    I can't always submit a CL Post when you (telerik) helped me.
    This would exceed your server capacity :)

    Manfred
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017