2012-11-06 1 views
2

Extjs 직접 프록시를 사용하여 목록에서 w.r.t 항목을로드 한 저장소가 있습니다.Extjs를 통해 보낸 ajax 요청을 선택적으로 중단합니다. 직접 프록시

proxy : { 
       type: 'direct', 
       api: { 
        read: bomManagementAction.bomQuickDetails 
       }      
       } 

이고 응답은 격자 패널에 표시됩니다.
더 많은 수의 항목을 선택하면 완료하는 데 시간이 오래 걸립니다. 따라서 더 긴 요청이 보류 중이고 짧은 요청을 보낸 경우 분명히 표가 후자로 업데이트됩니다. 이전 요청이 완료되면 그리드는 이전 버전과 다시 업데이트됩니다. 나는 'autoabort'설정은 'Ext.data.Connection'클래스에 있는지 알게하지만 selectivly 취소 저장로드와 비슷한 문제를 가지고

답변

5

하지 proxy.direct에 ...
은 도움을 주시기 바랍니다. Ext.Ajax.abort (request)는 요청을 중단 할 수 있습니다. 그러나 저장소에서 현재 요청 객체 (또는 더 나은, 요청 객체 Ext.Ajax.abort 필요)를 가져 오는 것은 꽤 어렵습니다.

... 
if (store.loading && store.lastOperation) { 
    var requests = Ext.Ajax.requests; 
    for (id in requests) 
    if (requests.hasOwnProperty(id) && requests[id].options == store.lastOperation.request) { 
     Ext.Ajax.abort(requests[id]); 
    } 
} 
store.on('beforeload', function(store, operation) { 
    store.lastOperation = operation; 
}, this, { single: true }); 

store.load(); 
... 

좋은 있지만, 지속적인 매장 부하를 안정적으로 취소되지 않음 :

마지막으로 나는이 있어요.

아마 Extjs Direct 연결에 대한 아이디어를 변형시킬 수 있습니다.

+0

TNX :

내가 직접 질문에 대답하고있어 확실하지 않다하지만

, 나는 솔루션과 같이되는 비슷한 시나리오를했다. 여기에 구현 완료 : http://code.tonytuan.org/2014/03/extjs-abort-store-connection-request.html – avidenic

0

내가 알 수있는 바로는 직접 호출에 대해 Ajax.abort()이 작동하지 않습니다 (서버에 전송 된 요청이 직접 엔진에서 자체적으로 처리하므로 서버에서 보낸 요청과 다릅니다).

/** 
* A proxy class that ensures only the reponse to the last read request is 
* processed. 
* 
* A quick user actions may result in more than one request sent to the server, 
* but it is possible for the server to return a response to the second request 
* before returning that of the first request. This will mean the the store 
* will be populated with records that do not correspond to the latest user 
* action. 
* 
*/ 

Ext.define('Ext.data.proxy.SerialDirect', { 

    extend: 'Ext.data.proxy.Direct', 
    alternateClassName: 'Ext.data.DirectSerialProxy', 

    alias: 'proxy.serialdirect', 

    doRequest: function(operation, callback, scope) { 
     this.callParent(arguments); 

     // Store the last read request 
     if (operation.request.action == "read") { 
      this.lastReadRequest = operation.request; 
     } 
    }, 

    processResponse: function(success, operation, request, response, callback, scope) {    
     // abort if the request is a read one and does not correspond to the 
     // last read request 
     if (request.action == "read" && request != this.lastReadRequest) 
      return; 

     this.callParent(arguments); 
    } 
}); 
관련 문제