Sunday, June 6, 2010

FilterFunction in ArrayCollection

Each time I have to implement an array filter, I find myself deeply impressed with the Flex ArrayCollection Filterfunction feature. 
If only they had it in Flash... If you are not familiar with it - here goes: 
FilterFunction is an ArrayCollection property allowing the definition of filter conditions for the data.
The function receive each object from the array and decide if it should be filtered out or not.
The result is returned as a boolean value.
Since this function can combine as many validation terms as we wish, it can easily implement multiple filters.
Here is a little sample. Just type inside the Filter field: 




I used "toLowerCase" in order to disable the case sensitivity. 
Also, the function looks for the input text anywhere in each listed country (not only at the beginning). 
And yes, I know not all the countries are listed...
Source code is here.

No comments:

Post a Comment

About Me

My photo
I've been developing Internet and rich-media application for 15 years. In my work I emphasis usability and best user experience as well as sleek design. My main expertise are JavaScript, Flex and Flash.

Followers