【问题标题】:DataSource transport.destroy called +1 times for each successive delete (recalled for previously deleted items)DataSource transport.destroy 为每个连续删除调用 +1 次(为先前删除的项目调用)
【发布时间】:2014-10-20 14:32:32
【问题描述】:

我的代码中有一个支持destroyDataSource。为了从中删除对象,我直接调用remove,即

myDataSource.remove(discardedData);

我的行为类似于this。但是,与链接线程不同,我的 destroy 没有设置为函数,因此该解决方案对我没有帮助。

我的数据源(我包括了所有这些,以防我的某些配置受到指责):

       var QueueMessages = {
        type: "aspnetmvc-ajax",
        transport: {
            read: {
                url: BASE_URL + "api/QueueMessages/GetMessagesHeaders",
                dataType: "json",
                type: "GET",
                beforeSend: function (req) {
                    req.setRequestHeader('Authorization', authService.getAuth());
                }
            },
            destroy: {
                url: BASE_URL + "api/QueueMessages/deleteMessage",
                dataType: "json",
                type: "DELETE",
                beforeSend: function (req) {
                    req.setRequestHeader('Authorization', authService.getAuth());
                }
            }
        },
        schema: {
            model: {
                id: "id",
                fields: {
                    profileName: { type: "string" },
                    queueType: { type: "string" },
                    acceptedAt: { type: "date" },
                    processedAt: { type: "date" },
                    BodyExcerpt: { type: "string" }
                }
            },
            total: "total",
            data: "data",
        },
        error: function (e) {
            //throw user back to login page
            if (e.errorThrown === "Unauthorized")
                $rootScope.$apply($location.path('/'));
        },
        requestStart: function () {
        },
        requestEnd: function () {
        },
        pageSize: 50,
        serverPaging: true,
        serverFiltering: true,
        serverSorting: true,
        serverGrouping: true,
        serverAggregates: true
    };

我找不到任何关于为什么会发生这种情况的线索。

【问题讨论】:

  • 问题可能与您引用的链接中的相同:执行破坏的结果并未告知它已正确完成。您的服务应返回适当的结果,以通知 destroy 它已被实际删除。

标签: kendo-ui kendo-grid kendo-datasource


【解决方案1】:

感谢OnaBai我找到了问题。

咨询 RFC 7231,我将 http DELETE 响应从 200 OK 更改为 204 no content

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-10-24
    • 2017-07-31
    • 1970-01-01
    • 2015-08-30
    • 1970-01-01
    • 2012-06-24
    • 2011-08-24
    • 1970-01-01
    相关资源
    最近更新 更多