【问题标题】:How to cancel all grid store XHR requests but the last [dojo dgrid]?如何取消除最后一个 [dojo dgrid] 之外的所有网格存储 XHR 请求?
【发布时间】:2014-05-06 15:42:40
【问题描述】:

我正在使用dojo dgrid 0.3.14

我有实时搜索工具栏

在每次用户输入更改时我都会做

    searchGrid.set("store", searchStore, query);

它工作正常,但后端无序返回数据。

因此,有时网格会因先前响应缓慢而刷新。

如何取消除最后一个以外的所有网格存储 XHR 请求?

DGrid 的当前解决方案是

   _abortQuery: function () {
       // console.log("_abortQuery" , this._refreshDeferred);
        if (this._refreshDeferred && this._refreshDeferred.cancel){
            this._refreshDeferred.cancel();
        }
        return this;
    },

    refresh: function () {
             this._abortQuery();
        return this.inherited(arguments);
    },

【问题讨论】:

    标签: dojo store abort dgrid


    【解决方案1】:

    如果您在每次按键时都响应用户输入,我建议您不要寻求取消请求,而是取消输入。为此,dgrid 在dgrid/util/misc 中有一个名为debounce 的实用函数。去抖动是指监听事件的做法,但只有在事件停止触发一段时间后才响应。

    更多信息请参见https://github.com/SitePen/dgrid/wiki/misc

    【讨论】:

    • request 1 started at 12:00:00, returned at 12:00:10, request 2 started at 12:00:05, returned and shown at 12:00:08. debounce 如何帮助不显示请求 1 的结果?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-03
    • 1970-01-01
    • 2012-01-18
    • 2016-10-17
    • 1970-01-01
    • 2013-10-19
    相关资源
    最近更新 更多