filterFunction

[FONT=Times New Roman][SIZE=3]Hello, I’m trying to use filterFunction to filter part of the data that is an ArrayCollection and it’s showed in a datagrid. Well, I don’t know if this class can only be applied using coldfusion, because I think that the only thing which cold fusion does is get the data from the database. So I’m getting the data from a database that is available in ArrayCollection of objects which is called [/SIZE][/FONT][FONT=‘Lucida Console’]myServiceData[/FONT][FONT=Times New Roman][SIZE=3]. In my application I want to choose in a combo determined period that my data in the database was modified and display it in the datagrid. There is the date field already to be consulted. There is also a class called [/SIZE][/FONT][FONT=‘Lucida Console’]DateMath[/FONT][FONT=Times New Roman][SIZE=3] that return date wished.[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3]Here is the code:[/SIZE][/FONT]
[FONT=Times New Roman][SIZE=3] [/SIZE][/FONT]


[FONT='Lucida Console']<mx:Script>[/FONT]
[FONT='Lucida Console']<![CDATA[[/FONT]
[FONT='Lucida Console'] [/FONT]
**[COLOR=blue][FONT='Lucida Console']private[/FONT][/COLOR]**[FONT='Lucida Console'] **var** periodArray:Array = ["Today", "This Week", "This Month", "Last 3 Months"];[/FONT]
**[COLOR=blue][FONT='Lucida Console'][Bindable][/FONT][/COLOR]**
**[COLOR=blue][FONT='Lucida Console']public[/FONT][/COLOR]**[FONT='Lucida Console'] **var** periodCollection:ArrayCollection = new ArrayCollection(periodArray);[/FONT]
[FONT='Lucida Console'] [/FONT]
**[COLOR=blue][FONT='Lucida Console']public[/FONT][/COLOR]**[FONT='Lucida Console'] **function** periodFilter():void[/FONT]
[FONT='Lucida Console']  {[/FONT]
[FONT='Lucida Console']  **[COLOR=blue]if[/COLOR]** (comboPeriod.selectedIndex == 3)[/FONT]
[FONT='Lucida Console']    {[/FONT]
[FONT='Lucida Console']    myServiceData.filterFunction = null;[/FONT]
[FONT='Lucida Console']    }[/FONT]
[FONT='Lucida Console']  **[COLOR=blue]else[/COLOR]**[/FONT]
[FONT='Lucida Console']    {[/FONT]
[FONT='Lucida Console']    myServiceData.filterFunction = periodFilterFunction;[/FONT]
[FONT='Lucida Console']    }[/FONT]
[FONT='Lucida Console']  myServiceData.refresh();[/FONT]
[FONT='Lucida Console']  }[/FONT]
[FONT='Lucida Console']                  [/FONT]
**[COLOR=blue][FONT='Lucida Console']public[/FONT][/COLOR]**[FONT='Lucida Console'] **function** periodFilterFunction(data):Boolean[/FONT]
[FONT='Lucida Console']  {[/FONT]
[FONT='Lucida Console']  **var** now:Date = new Date();[/FONT]
[FONT='Lucida Console']  **var** dateMath:DateMath = new DateMath();[/FONT]
[FONT='Lucida Console']  **var** dateToFilter:Date = new Date();[/FONT]
[FONT='Lucida Console']            [/FONT]
[FONT='Lucida Console']  **[COLOR=blue]switch[/COLOR]** (comboPeriod.selectedIndex)[/FONT]
[FONT='Lucida Console']    {[/FONT]
[FONT='Lucida Console']    **case** 0:[/FONT]
[FONT='Lucida Console']      dateToFilter = dateMath.addDays(now, -1);[/FONT]
[FONT='Lucida Console']      break;[/FONT]
[FONT='Lucida Console']    **case** 1:[/FONT]
[FONT='Lucida Console']      dateToFilter = dateMath.addWeeks(now, -1);[/FONT]
[FONT='Lucida Console']      break;[/FONT]
[FONT='Lucida Console']    **case** 2:[/FONT]
[FONT='Lucida Console']      dateToFilter = dateMath.addWeeks(now, -4);[/FONT]
[FONT='Lucida Console']      break;[/FONT]
[FONT='Lucida Console']    }[COLOR=lime][/COLOR][/FONT]
[COLOR=lime][FONT='Lucida Console']  //return (dateToFilter < data.creation);[/FONT][/COLOR]
[FONT='Lucida Console']  **[COLOR=blue]return[/COLOR]** **[COLOR=blue]true[/COLOR]**;[/FONT]
[FONT='Lucida Console']  }[/FONT]
[FONT='Lucida Console']]]>[/FONT]
[FONT='Lucida Console']</mx:Script>[/FONT]
[FONT='Lucida Console'] [/FONT]
[FONT='Lucida Console']<mx:ComboBox id="comboPeriod" selectedIndex="3" dataProvider="{periodCollection}"[/FONT]
[FONT='Lucida Console']change="periodFilter()"></mx:ComboBox>[/FONT]

Just wondering how do I use filterfunction to filter the date that I got.
Thank you very much.