在Store中加载监听器

时间:2016-11-24 11:57:42

标签: extjs extjs4

我在我的商店使用加载侦听器。

https://docs.sencha.com/extjs/4.1.0/source/AbstractStore.html#Ext-data-AbstractStore-event-load

listeners: {
    load: function (store, records, success, opts) {

    }
}

如果 success = false ,我想收到一条错误消息,或者来自HTTP响应的错误消息。

我在哪里可以获得这些信息?

1 个答案:

答案 0 :(得分:1)

您正在寻找商店代理中的exception事件。

查看这个小提琴https://fiddle.sencha.com/#view/editor&fiddle/1l5m

Ext.define('MyApp.store.MyJsonStore', {
    extend: 'Ext.data.Store',

    requires: [
        'Ext.data.proxy.Ajax',
        'Ext.data.reader.Json'
    ],

    autoLoad: true,
    storeId: 'MyJsonStore',
    proxy: {
        type: 'ajax',
        url: 'non-existing-data.json',
        reader: {
            type: 'json'
        },
        listeners: {
            exception: function (proxy, response, operation, eOpts) {
                // debugger;
            }
        }
    }
});
相关问题