PDA

View Full Version : Store's filter method is not working as expected



webfriend13
18 Feb 2013, 12:54 AM
I have a store which is having a model. Model contains three fields ID, Name, age. This store is attached to a grid.
This is how the data looks:

41910


I user filter function on the store to apply filter.
So when i apply filter on Id 'Manu', i see two results in grid myStore.filter('ID', 'Manu'); //Works fine
Problem myStore.filter('ID', 'Sales'); // retuns 4 results. It also includes result for ID 'Sales One' and 'Sales Two'
What I Want: When I filter on 'Sales' ID, it should return only results for ID 'Sales'.

mixo
18 Feb 2013, 1:08 AM
webfriend13 you can define filter function for filter with conditions which you like


store.filter([ {property: "email", value: /\.com$/}, {filterFn: function(item) { return item.get("age") > 10; }} ]);

webfriend13
18 Feb 2013, 1:42 AM
HI Mixo,

Thank you for quick reply. I will try the solution you gave but I tried this code and its working. I think your solution is same as below solution. +1 for that =D>. Thank you




myStore.filter([ {filterFn: function(item) { return item.get('ID') == 'Sales'; }} ]);