Flex Filterfunction - Filter by Array of values
Posted
by
Anandh
on Stack Overflow
See other posts from Stack Overflow
or by Anandh
Published on 2011-03-17T15:35:38Z
Indexed on
2011/03/17
16:09 UTC
Read the original article
Hit count: 173
flex
|actionscript-3
How to filter an Arraycollection by "array of values" rather than a single value (simple comparision) , the below code snippet is for filtering by single value now I went into scenario like filter out only price [10,4,1,8] (some random values from the master collection). Is there any better way to do the second code snippet
Filter function simple comparision
private function filterForTestData(item:Object):Boolean{
if(item.price < slider.value) return true;
else return false;
}
Filter by array of values
private function filterForTestData(item:Object,filterBy:Array= [10,4,1,8]):Boolean{
for(randomprice in filterBy)
return item.price == randomprice;
}
[Edited]
Apply Filter
testData.filterFunction = filterForTestData;
© Stack Overflow or respective owner