如何在 ExtJS 5 的 Ajax 代理中监听成功? [英] How can I listen for success in an Ajax Proxy in ExtJS 5?

查看:31
本文介绍了如何在 ExtJS 5 的 Ajax 代理中监听成功?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有 RowEditing 插件的网格,其 Store 的 AjaxProxy 使用 JsonWriter 将更新写回服务器.

I have a grid with the RowEditing plugin whose Store's AjaxProxy uses a JsonWriter to write updates back to the server.

发生更新时,我需要触发一些代码来更新另一个组件,这需要单独访问服务器.

When an update occurs, I need to fire some code to update another component, which requires a separate trip to the server.

必须在 JsonWriter 返回后触发,因为它取决于服务器上正在更新的数据.因此,我无法侦听商店的更新"事件,因为它发生在 Ajax 调用之前(即使禁用了批处理).

This has to fire after the JsonWriter comes back, since it depends on the data being updated on the server. So, I can't listen for the store's "update" event, since that occurs before the Ajax call is made (even with batching disabled).

我尝试为endupdate"设置一个侦听器,如下所示,但在发出 AJAX 请求之前再次触发:

I tried putting a listener for "endupdate", as follows, but that again fires before the AJAX request is made:

        var ds = new Ext.data.Store({
            model:      modelname,
            autoSync:   true,
            proxy: {
                type:           "ajax",
                api: {
                    create:     "ajax.aspx?xaction=create",
                    read:       "ajax.aspx?xaction=read",
                    update:     "ajax.aspx?xaction=update",
                    destroy:    "ajax.aspx?xaction=destroy"
                },
                batchActions:   false,
                reader:         { type: "json", rootProperty: "rows", totalProperty: "results" },
                writer:         { type: "json", encode: true, writeAllFields: true, rootProperty: "rows" }
            },
            listeners: {
                load:       { fn: reloadPreview },
                endupdate:  { fn: reloadPreview }
            }
        });

对于作者的更新"调用,我没有从服务器发回任何响应......我似乎找不到关于 AjaxProxy 或 JsonWriter 期望返回什么的任何文档,并且发送空白响应似乎有效.

I don't send any response back from the server for the writer's "update" call... I can't seem to find any documentation on what AjaxProxy or JsonWriter is expecting back, and sending a blank response seems to work.

推荐答案

您是否尝试为写入"事件添加侦听器?

Did you try to add listener to "write" event ?

write(store, operation, eOpts) 每当成功写入时触发通过配置的代理进行

write( store, operation, eOpts ) Fires whenever a successful write has been made via the configured Proxy

http://docs.sencha.com/extjs/5.0.0/apidocs/#!/api/Ext.data.Store-event-write

这篇关于如何在 ExtJS 5 的 Ajax 代理中监听成功?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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