apache-flexfilterfilterfunction

filter functions problem


I'm working on a search component for an app I'm working on and I needed to add some filters to it. I've found an example and got the first filter working fine.

Now I'm trying to add a second filter I'm running into problems... In the example I found they use filterFunctions, but I only get an option for filterFunction, why is that?

Here's the example code

   productsCollection.filterFunctions =
[
 filterByPrice, filterByType,
 filterByCondition, filterByVendor
]

And this is what I'm trying

acData.filterFunction = [filterByStatus, filterByDate]

but with this code I get the following error message - 1067: Implicit coercion of a value of type Array to an unrelated type Function.

Why am I getting this error and how would I go about add multiple filters to my Array Collection?

Thanks!


Solution

  • filterFunction must be set to a single function, not an Array or any other datatype. To combine multiple functions create one that combines them, like this:

    acData.filterFunction = function(item:Object) 
        {
             return
                 filterByPrice(item) &&
                 filterByType(item) &&
                 filterByCondition(item) &&
                 filterByVendor(item);
        };
    

    If you saw a sample that used filterFunctions plural that accepted an array, post a link. That's not anywhere in the standard Flex framework or in the new 4.0 beta afaik.