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

Ajax events not triggered by FileExplorer

6 Answers 135 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
ManniAT
Top achievements
Rank 2
ManniAT asked on 22 Apr 2009, 09:54 AM
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

6 Answers, 1 is accepted

Sort by
0
ManniAT
Top achievements
Rank 2
answered on 22 Apr 2009, 01:52 PM
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!
0
Accepted
Lini
Telerik team
answered on 27 Apr 2009, 12:06 PM
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.
0
ManniAT
Top achievements
Rank 2
answered on 27 Apr 2009, 12:12 PM
Hi Lini,

great solution - and queuing already implemented :)

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

Manfred
0
Tervel
Telerik team
answered on 27 Apr 2009, 12:24 PM
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.
0
ManniAT
Top achievements
Rank 2
answered on 27 Apr 2009, 12:30 PM
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
0
ManniAT
Top achievements
Rank 2
answered on 27 Apr 2009, 12:43 PM
An extra note Tervel,

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

Manfred
Tags
FileExplorer
Asked by
ManniAT
Top achievements
Rank 2
Answers by
ManniAT
Top achievements
Rank 2
Lini
Telerik team
Tervel
Telerik team
Share this question
or