拡張ExtJSの【Ext.data.reader.Json】例
1869 ワード
一、次は拡張Class
二、これはClassを拡張する場所です.
//END
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