Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: How do I abort store.load() command?

    You found a bug! We've classified it as EXTJS-11109 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Jun 2011
    Posts
    15

    Default How do I abort store.load() command?

    As the title says: how do I cancel store.load() command using ExtJS 4.0.1?

    I used to be able to do this in ExtJS 3.2.1 like this:
    PHP Code:
    var activeRequest Ext.getCmp('myGrid').getStore().proxy.activeRequest;

    // Abort the loading procedure if there is old load in progress
    if (typeof activeRequest.read != 'undefined')     
    {    
        
    Ext.Ajax.abort(activeRequest.read);     

    I see that there still is Ext.Ajax.abort command in 4.0.1, but I cannot get the activeRequest from anywhere... I know that I could get the request if I did the AJAX loading with Ext.Ajax.load(), but I need to be able to abort all kinds of ajax loads, like grid, combo, etc., and I cannot get the request object from there.

    Btw. Why isn't there an abort() command under Ext.data.Proxy.Ajax, like there is under Ext.data.Proxy.JsonP? Seems to me this would be very nice command.

  2. #2
    Sencha User
    Join Date
    Jun 2011
    Posts
    15

    Default

    Bump. Anyone?

  3. #3
    Sencha User
    Join Date
    May 2010
    Posts
    45

    Default

    I haven't tried, but you can give it a go...

    PHP Code:
    var requestId store.getRequestId();

    Ext.Ajax.abort(requestId); 
    or you can always extend the class and implement it...

  4. #4
    Sencha User
    Join Date
    Jun 2011
    Posts
    15

    Default

    Thanks for your reply. The getRequestId() seems to work, but in ExtJS 4.0+ the Ext.Ajax.abort() needs a request object, instead of requestID like it was in ExtJS 3. Any idea how I get the request object from store, or should I create it somehow?
    Last edited by Hooveri; 10 Jun 2011 at 1:07 AM. Reason: Typos

  5. #5
    Sencha User
    Join Date
    May 2010
    Posts
    45

    Default

    true, you might have to extend the class and implement it your self.

  6. #6
    Sencha User
    Join Date
    Jun 2011
    Posts
    15

    Default

    I did some more research on this one. Seems that the getRequestId() cannot be used, because it seems to only create ids, instead of returning the previous transaction id. And it seems to be only used when using buffered loading.

    I did, however, found a way to get the Request object, if I only could get the transaction id of store load...

  7. #7
    Sencha User
    Join Date
    Jun 2011
    Posts
    15

    Default

    I think I figured it out now. Not so nice piece of code like it was back in the ExtJS 3, but it does the job:

    Ext.data.proxy.Ajax
    PHP Code:
    doRequest: function(operationcallbackscope) {
        var 
    writer  this.getWriter(),
            
    request this.buildRequest(operationcallbackscope);
            
        if (
    operation.allowWrite()) {
            
    request writer.write(request);
        }
        
        
    Ext.apply(request, {
            
    headers       this.headers,
            
    timeout       this.timeout,
            
    scope         this,
            
    callback      this.createRequestCallback(requestoperationcallbackscope),
            
    method        this.getMethod(request),
            
    disableCachingfalse // explicitly set it to false, ServerProxy handles caching
        
    });
        
        
    // Added this line of code to keep track of latest request object
        
    this.latestRequest Ext.Ajax.request(request);
        
        return 
    request;

    So basically I just store the request object at the proxy. Then I made a get function that I use to fetch "latestRequest" when I need it. Feel free to suggest cleaner solution if you got one.

    Would be nice if this functionality was build in to proxy because it's not really uncommon, that you need to abort some ajax call.

  8. #8
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,035

    Default

    I need to look at this at some point; I'm amazed that it's not in there already, especially for tree stores which could be in the process of loading when you change it's context, updating it's root node.

    I've actually had to attach an external load id via extraParams so I can throw away responses when they come back for a tree that has now been replaced

    Thanks for the tips here, I'll have a play.

    Cheers,
    Westy
    Product Architect
    Altus Ltd.

  9. #9
    Sencha Premium User westy's Avatar
    Join Date
    Feb 2009
    Location
    Bath, UK
    Posts
    1,035

    Default

    I notice Ext.data.Connection has an abort method, which takes an optional request.
    It defaults to the last request made so may be useful for some...

    Not sure if a direct batched call counts as one or multiple requests, but I'm guessing one.
    Product Architect
    Altus Ltd.

  10. #10
    Sencha User
    Join Date
    Jun 2011
    Posts
    15

    Default

    Yup. I found this one too, but its' not good enough in some cases.

    I might have up to three AJAX calls running simultaneously, and I might need to abort just one of them (not necessary the last one). So the last request must be stored someplace (at store or proxy) so I can target the one request I really want to abort.
    Last edited by Hooveri; 14 Jun 2011 at 3:03 AM. Reason: Clarification

Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •