View Full Version : Filter properties that have the same value

29 May 2012, 6:44 AM

I wanted to filter or get all the items from a tree with a given property that have the same value:

For example this gives me an array of all the directRequestId items that aren't empty. I would like to go one step further and somehow give me all the directRequestId that have the same value?

Not sure if that is possible in one filter?

getDirectRequestIds: function() {
var treeData = this.tree;

return Ext.Array.filter(treeData.flatten(), function(item) {
return item.get("directRequestId") != "";


29 May 2012, 8:21 AM
Have a look at treeStore.filters that references Ext.util.filter where you can setup a filter object.


29 May 2012, 1:54 PM

However if I don't know what tha value of the fields are going to be until i retrieve them I'm not sure how I can apply the filter. For example if you have 4 directRequestIds and out of the 4 two are the same. This is a value that is entered in a field. So for example say you had, football, cricket, judo, football

How would I apply one filter to say that item 1 and item 4 are the same, or would I need to apply a filter for each directRequestId that comes back and then see if there is more than one item?