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

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

问题描述

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



当更新发生时,我需要点燃一些要更新另一个组件的代码,需要单独访问服务器。



这必须在JsonWriter返回之后触发,因为它依赖在服务器上更新的数据。所以我听不到这个商店的更新事件,因为发生在Ajax调用之前(即使是禁止批处理)。



endupdate的侦听器,如下所示,但在AJAX请求发生之前再次触发:

  var ds = new Ext。 data.Store({
model:modelname,
autoSync:true,
proxy:{
type:ajax,
api:{
create :ajax.aspx?xaction = create,
读取: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,writ eAllFields:true,rootProperty:rows}
},
listeners:{
load:{fn:reloadPreview},
endupdate:{fn:reloadPreview}
}
});

我不会从服务器发回任何回应作者的更新电话我似乎没有找到关于AjaxProxy或JsonWriter所期待的任何文档,并发送一个空白的响应似乎有效。

解决方案

p>您是否尝试将侦听器添加到写入事件?


write(store,operation,eOpts)
通过配置的代理


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


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.

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

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 }
            }
        });

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 ) 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天全站免登陆