当前位置: 代码迷 >> JavaScript >> 扩充ExtJS的【Ext.data.reader.Json】例子
  详细解决方案

扩充ExtJS的【Ext.data.reader.Json】例子

热度:871   发布时间:2012-06-28 15:20:03.0
扩展ExtJS的【Ext.data.reader.Json】例子

一,下面是扩展Class

?

Ext.define('Dncsoft.data.MyReader', {
    extend: 'Ext.data.reader.Json',
    alternateClassName: 'Ext.data.DncReader',
    alias : 'reader.dncreader',
    
    startDate: new Date(),
    endDate: new Date(),
    
    getResponseData: function(response) {
        var me = this;
        var data = me.callParent(arguments);
        return me.change(data);
    },
    
    change: function(sourceJson) {
        var me = this;
        
        // filter data and sum value
        var map = new Ext.util.HashMap();
        for (var i = 0, iEnd = sourceJson.length; i < iEnd; ++i) {
            map.add(_id, {"id":_id, "v":_v});
        }
        
        return map.getValues();
    }
});

?

二,这是用扩展Class的地方。

?

var store = Ext.create('Ext.data.JsonStore', {
    model: 'Dncsoft.data.MyModel',
    buffered: true,
    purgePageCount: 0,
    proxy: {
        type: 'ajax',
        url: 'mydata.json',
        noCache: true,
        filterParam: undefined,
        groupParam: undefined,
        limitParam: undefined,
        startParam: undefined,
        sortParam: undefined,
        pageParam: undefined,
        reader: {
            model: 'Dncsoft.data.MyModel',
            type: 'dncreader',
            root: 'root',
            startDate: new Date('1/15/2011'),
            endDate: new Date('2/31/2013')
        }
    },
    autoLoad: false
});

?

?

?

//END

  相关解决方案