Reputation: 197
I have a store containing scores.I need to filter out than score >10 and less than 3. Is it possible to filter out data. I tried:
Ext.getStore('MyStore').clearFilter(true);
var RStore = Ext.getStore('MyStore');
RStore.filter('score', '2');
this is working.but it filters fields having score 2. I need to the store data having score >10....
I saw a stack link it is not possible
Extjs 4 remote filter store smaller (<) bigger (>) than
Pls help me to have this.
Upvotes: 1
Views: 5304
Reputation: 5700
Try this:
var store = Ext.getStore('MyStore');
store.clearFilter(true);
store.filterBy(function(record, id){
if(record.get("score") < 3 || record.get("score") > 10){
return true;
}
return false;
}, this);
You can see this in demo here: https://fiddle.sencha.com/#fiddle/1359
Upvotes: 3
Reputation: 71
You can do it like this as well:
var RStore = Ext.getStore('MyStore');
RStore.clearFilter(true);
RStore.filter([
{filterFn: function(item) { return item.get("score") > 10 || item.get("score") < 3; }}
]);
hope this helps.
Upvotes: 1
Reputation: 610
You can write your own filter function.
Have a look at: ExtJS-store-filterby
Upvotes: 1