I think this has been discussed before in this forum.

Someone where I work has subclassed XMLListCollection and hardcoded a
filterFunction that enumerates through a list / array of normal filter
functions, enforcing each one after another.

You don't need to subclasses anything though...just register a
filterFunction that somehow knows about the other filter functions. Knowing
about other filter functions might be done by encapsulating it in a separate
class.

I'm thinking this could be done by creating a BaseMultiFilter class that has
a filterFunction that handles filtering through multiple filter functions.
Those specific filter functions could be implemented and registered in a
subclass of BaseMultiFilter. Then apply the multi filter to the collection
using,

  collection.filterFunction = multiFilterSubclass.filterFunction;
  collection.refresh();
One biggy here is that you don't always want all the filter criteria to be
ANDed - sometimes the logic is more complicated but that could also be built
in!
So basically you loop through calling all your filterFunctions and as soon
as one fails, i.e. returns false, you return false from the main
filterFunction.

Hope that helps...and perhaps someone has a better or more concrete
implementation out there?

Do people prefer a separate MultiFilter class rather than hardcoding support
into ArrayCollection / XMLListCollection ?


On Wed, Jun 10, 2009 at 6:59 PM, munene_uk <[email protected]> wrote:

>
>
> thanks for clearing that up....
>
> do i need to create different filter functions for each criteria? e.g a
> function for size filtering and a function for colour filtering?
>
> 
>

Reply via email to