Ext JS 在商店 reader 之前读取 JSON 响应

Ext JS Read JSON response before reader in Store

我有 JSON 回复如下 -

{
"success": true,
"data": {
"data": [
    {
        "resultsMap": {
            "Title": "Test1",
            "Name": "Test1"
        },
        "id": 1
    },
    {
        "resultsMap": {
            "Title": "Test2",
            "Name": "Test2"
        },
        "id": 2
    }
],
"total": 2
}
}

我正在使用自定义 reader 来提取数据。问题是我丢失了来自服务器的初始 JSON 响应,我需要从中提取 "total"。有人可以帮助我从 json 响应中获取 "total" 吗?

var newStore = Ext.create('Ext.data.BufferedStore', {
            pageSize: 2000,
            fields:fields,
            //leadingBufferZone:50,
                   //trailingBufferZone:50,
            //autoLoad: {start: 0, limit: 2000},
            remoteSort: true,
               sorters: [{
                          property : 'name',
                          direction: 'asc'
                      }],
            proxy: {
                type: 'ajax',           
                url: 'getData.json',
                reader: {
                    type: 'nestedjsonreader',
                    rootProperty: 'data',
                    totalProperty:  function(data) {
                        //console.log(data);
                        return data.totalCount;
                    },
                },
                extraParams: {
                    id:ID
                }
            },
            listeners: {
                'load' : function(store, records, success, options){
                    //the complete response
                    console.log(store.getProxy().getReader().rawData);
                }
            }  
        });

Ext.define('Portal.model.NestedJsonReader', {
extend: 'Ext.data.reader.Json',
alias: 'reader.nestedjsonreader',

readRecords: function(data) {
    var arr = data.data.data;
    var data = [];
    if(arr!=undefined){
        for(var i=0;i<arr.length;i++){
            var obj = arr[i].resultsMap;
            data.push(obj);
        }
    }
    return this.callParent( [ data ]);
}
})

在您的商店中创建自定义 属性 作为 resp_total 并为其指定 data.total