有选择地中止通过Extjs Direct代理发送的ajax请求 [英] Selectively aborting an ajax request sent via Extjs Direct proxy

查看:78
本文介绍了有选择地中止通过Extjs Direct代理发送的ajax请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一家商店,使用Extjs直接代理从列表中加载了很多商品.

I have a store which is loaded w.r.t items from a list using Extjs direct proxy.

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

,响应将显示在网格面板中.
如果选择的项目数量较多,则需要较长时间才能完成,因此,如果有较长的请求待处理,并且如果我们发送了较短的请求,则肯定会使用后一个来更新网格,但是当前一个请求发生时会发生什么完成后,网格将重新使用不合需要的前者进行更新.我知道' autoabort '配置出现在' Ext.data.Connection '类中,但在proxy.direct中却没有...
请帮助

and the response is displayed in a grid panel.
If larger number of items are selected, it will take long time to complete , so if a longer request is pending and if we sent a short request , definitely the grid will be updated with the latter one , but what happens is when the former request completes then the grid will re update with the former one which is non desirable. I came to know that the 'autoabort' config is present in 'Ext.data.Connection' class but not in proxy.direct ...
please help

推荐答案

我在选择性取消商店负载时遇到了类似的问题. Ext.Ajax.abort(request)能够中止请求.但是很难从商店中获取当前的请求对象(或者更好的是,Ext.Ajax.abort需要的请求对象).

I got similar problems with selectivly canceling store loads. Ext.Ajax.abort(request) is able to abort requests. But it is pretty hard to get the current request object (or better, the request object Ext.Ajax.abort needs) from a store.

最后我得到了:

...
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();
...

不好,但是持久的存储负载已被可靠地取消.

Not nice but lasting store loads are reliably canceled.

也许可以将这种想法转变为Extjs Direct连接.

Maybe one can transform this idea for Extjs Direct connections.

这篇关于有选择地中止通过Extjs Direct代理发送的ajax请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆