我在WSAPI查询中传递了一个函数作为过滤器,但它似乎对返回的结果没有影响。是否有使用此方法无法过滤的字段?
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
Ext.create('Rally.data.WsapiDataStore', {
model : 'TestCase',
fetch : ['TestCases'],
filters : [
function(item) {
return item.FormattedID.indexOf('10') !== -1;
}
]
}).load({
callback: function(records) {
//All records returned, no filter applied
}
});
}
});
答案 0 :(得分:0)
我还希望您的代码能够正常工作,但是在应用客户端过滤器之前可能会发生回调。以下是应用过滤器的代码的修改版本,并且只按预期返回一条记录:
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
launch: function() {
var myStore = Ext.create('Rally.data.WsapiDataStore', {
model : 'TestCase',
fetch : ['FormattedID']
});
myStore.load({
callback: function(records) {
myStore.filterBy(function(item) {
return item.get('FormattedID').indexOf('10') !== -1;
});
console.log(myStore.getRange()); //one record
}
});
}
});