How can I listen for success in an Ajax Proxy in ExtJS 5?

坚强是说给别人听的谎言 提交于 2019-12-05 07:41:27

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/24663392/how-can-i-listen-for-success-in-an-ajax-proxy-in-extjs-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!