Reputation: 2140
I fill out an array dynamically with a list of Ids:
var allChildNodeIDs = [];
Ext.getCmp('categoriesTreePanel').getRootNode().eachChild(function(Mynode){
allChildNodeIDs.push(Mynode.data.idCategorie);
});
Then I want to filter a store according to all Ids contained in the array. For example if the array contains two values, I want that my store will be filtered like so:
myStore.filterBy(function(record) {
return (record.get('idCategorie') == allChildNodeIDs [1] && record.get('idCategorie') == allChildNodeIDs [2]);
});
But the array is filled out dynamically, and I don't know his length!
Upvotes: 0
Views: 1546
Reputation: 25001
It seems like the sorting function in your example would always return false
. I assume what you want to do is accept all the record which category is present into the array (i.e. that ou meant to use ||
instead of &&
).
You can use Array
's indexOf
method.
Example:
myStore.filterBy(function(record) {
return allChildNodeIDs.indexOf(record.get('idCategorie')) !== -1;
});
Upvotes: 1