1
我想使用自定义算法过滤Ext商店。 JSON/AJAX代理返回> 100条记录,我需要根据许多条件将数字减少到前5位。如何实现Ext.data.Store的自定义过滤算法
如何去解决这个问题(而不是算法,但在哪里触发它)?
我目前的做法是使用自定义的读者像这样
Ext.define('MyReader', {
extend : 'Ext.data.reader.Json',
alias : 'reader.myReader',
getResponseData : function(response) {
var data = this.callParent([response]);
// algorithm
return filteredData;
}
});
Ext.define('SunApp.store.Stations', {
extend: 'Ext.data.Store',
requires: ['MyReader'],
config: {
model: 'SunApp.model.Station',
autoLoad: true,
proxy: {
type: 'ajax',
url: 'data.json',
reader: {
type: 'myReader'
}
}
}
});
,但我宁愿立足于商店模式的算法比对原始JSON数据。因此,我想在数据加载到商店时过滤/过滤。请注意,显示的列表视图时,该店隐含分机创建:
Ext.define('SunApp.view.Stations', {
extend: 'Ext.List',
xtype: 'stations',
config: {
title: 'Stations',
store: 'Stations',
...
因此,我不能只是增加一个功能,我手动调用它被传递到列表前的商店。