<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flex Examples &#187; filterFunction</title>
	<atom:link href="http://blog.flexexamples.com/tag/filterfunction/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Filtering an MX DataGrid control by date range using Flex</title>
		<link>http://blog.flexexamples.com/2010/02/01/filtering-an-mx-datagrid-control-by-date-range-using-flex/</link>
		<comments>http://blog.flexexamples.com/2010/02/01/filtering-an-mx-datagrid-control-by-date-range-using-flex/#comments</comments>
		<pubDate>Tue, 02 Feb 2010 02:11:22 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ArrayCollection]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[DateField]]></category>
		<category><![CDATA[filterFunction]]></category>
		<category><![CDATA[refresh()]]></category>
		<category><![CDATA[selectableRange]]></category>
		<category><![CDATA[selectedDate]]></category>
		<category><![CDATA[time]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/?p=2366</guid>
		<description><![CDATA[<p>The following example shows how you can filter an MX DataGrid control in Flex using two MX DateField control&#8217;s and filtering the ArrayCollection data provider.</p> <p></p> &#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62; &#60;!-- http://blog.flexexamples.com/2010/02/01/filtering-an-mx-datagrid-control-by-date-range-using-flex/ --&#62; &#60;mx:Application name=&#34;MX_DataGrid_filter_DateField_test&#34; xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;vertical&#34; verticalAlign=&#34;middle&#34; backgroundColor=&#34;white&#34; initialize=&#34;init();&#34;&#62; &#160; &#60;mx:Script&#62; &#60;![CDATA[ protected const MIN_DATE:Date = new Date(2010, 0, 1); protected const MAX_DATE:Date = new [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can filter an MX DataGrid control in Flex using two MX DateField control&#8217;s and filtering the ArrayCollection data provider.</p>
<p><span id="more-2366"></span></p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2010/02/01/filtering-an-mx-datagrid-control-by-date-range-using-flex/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Application</span> name=<span style="color: #ff0000;">&quot;MX_DataGrid_filter_DateField_test&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span></span>
<span style="color: #000000;">        layout=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #000000;">        verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span></span>
<span style="color: #000000;">        initialize=<span style="color: #ff0000;">&quot;init();&quot;</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #339933;">&lt;mx:Script&gt;</span>
<span style="color: #339933;">        &lt;![CDATA[</span>
<span style="color: #339933;">            protected const MIN_DATE:Date = new Date(2010, 0, 1);</span>
<span style="color: #339933;">            protected const MAX_DATE:Date = new Date(2010, 11, 31);</span>
&nbsp;
<span style="color: #339933;">            protected function date_labelFunc(item:Object, col:DataGridColumn):String {</span>
<span style="color: #339933;">                var time:Number = Date.parse(item[col.dataField]);</span>
<span style="color: #339933;">                return new Date(time).toDateString();</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            protected function arrColl_filterFunc(item:Object):Boolean {</span>
<span style="color: #339933;">                var cDate:Number = Date.parse(item.holidayDate);</span>
&nbsp;
<span style="color: #339933;">                if (!sDate || !eDate) {</span>
<span style="color: #339933;">                    return true;</span>
<span style="color: #339933;">                }</span>
&nbsp;
<span style="color: #339933;">                if (sDate.selectedDate &amp;&amp; eDate.selectedDate) {</span>
<span style="color: #339933;">                    return (sDate.selectedDate.time &lt;= cDate) &amp;&amp; (eDate.selectedDate.time &gt;= cDate);</span>
<span style="color: #339933;">                } else if (sDate.selectedDate) {</span>
<span style="color: #339933;">                    return sDate.selectedDate.time &lt;= cDate;</span>
<span style="color: #339933;">                } else if (eDate.selectedDate) {</span>
<span style="color: #339933;">                    return eDate.selectedDate.time &gt;= cDate;</span>
<span style="color: #339933;">                } else {</span>
<span style="color: #339933;">                    return true;</span>
<span style="color: #339933;">                }</span>
<span style="color: #339933;">            }</span>
&nbsp;
<span style="color: #339933;">            protected function init():void {</span>
<span style="color: #339933;">                sDate.selectedDate = MIN_DATE;</span>
<span style="color: #339933;">                sDate.selectableRange = {rangeStart:MIN_DATE, rangeEnd:MAX_DATE};</span>
&nbsp;
<span style="color: #339933;">                eDate.selectedDate = MAX_DATE;</span>
<span style="color: #339933;">                eDate.selectableRange = sDate.selectableRange;</span>
<span style="color: #339933;">            }</span>
<span style="color: #339933;">        ]]&gt;</span>
<span style="color: #339933;">    &lt;/mx:Script&gt;</span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ArrayCollection</span> id=<span style="color: #ff0000;">&quot;arrColl&quot;</span> filterFunction=<span style="color: #ff0000;">&quot;arrColl_filterFunc&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:source</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Array</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;New Years&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/1/1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Martin Luther King, Jr. Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/1/18&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Groundhog Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/2/2&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Chinese New Year&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/2/14&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Valentine's Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/2/14&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;President's Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/2/15&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Ash Wednesday&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/2/17&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Daylight Saving Time starts&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/3/14&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;St. Patrick's Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/3/17&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;First Day of Spring&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/3/20&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;April Fool's Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/4/1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Easter&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/4/4&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Administrative Professional's Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/4/21&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Earth Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/4/22&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Cinco De Mayo&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/5/5&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Mothers Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/5/9&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Armed Forces Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/5/15&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Memorial Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/5/31&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Flag Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/6/14&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Father's Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/6/20&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Summer Begins&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/6/21&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Independence Day/July 4th&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/7/4&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Labor Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/9/6&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Grandparents Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/9/12&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;First Day of Autumn&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/9/23&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Columbus Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/10/11&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;United Nations Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/10/24&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Halloween&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/10/31&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;All Saints' Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/11/1&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Daylight Saving Time Ends&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/11/7&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Veteran's Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/11/11&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Thanksgiving&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/11/25&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
&nbsp;
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Wright Brothers Day&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/12/17&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;First Day Winter&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/12/21&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;Christmas&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/12/25&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Object</span> holidayName=<span style="color: #ff0000;">&quot;New Years Eve&quot;</span> holidayDate=<span style="color: #ff0000;">&quot;2010/12/31&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Array</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:source</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ArrayCollection</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:ApplicationControlBar</span> dock=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Start date:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DateField</span> id=<span style="color: #ff0000;">&quot;sDate&quot;</span> change=<span style="color: #ff0000;">&quot;arrColl.refresh();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;End date:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DateField</span> id=<span style="color: #ff0000;">&quot;eDate&quot;</span> change=<span style="color: #ff0000;">&quot;arrColl.refresh();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:ApplicationControlBar</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGrid</span> id=<span style="color: #ff0000;">&quot;dGrid&quot;</span> dataProvider=<span style="color: #ff0000;">&quot;{arrColl}&quot;</span> width=<span style="color: #ff0000;">&quot;400&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:columns</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> dataField=<span style="color: #ff0000;">&quot;holidayName&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> dataField=<span style="color: #ff0000;">&quot;holidayDate&quot;</span> labelFunction=<span style="color: #ff0000;">&quot;date_labelFunc&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:columns</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:DataGrid</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/MX_DataGrid_filter_DateField_test/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://dl.dropbox.com/u/4509565/FlexExamples_com/MX_DataGrid_filter_DateField_test/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Filtering an MX DataGrid control by date range using Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2010/02/01/filtering-an-mx-datagrid-control-by-date-range-using-flex/',contentID: 'post-2366',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'filterFunction,refresh(),selectableRange,selectedDate,time',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2010/02/01/filtering-an-mx-datagrid-control-by-date-range-using-flex/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>Filtering an XMLListCollection using Regular Expressions</title>
		<link>http://blog.flexexamples.com/2009/04/01/filtering-an-xmllistcollection-using-regular-expressions/</link>
		<comments>http://blog.flexexamples.com/2009/04/01/filtering-an-xmllistcollection-using-regular-expressions/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 06:59:11 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta2]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[RegExp]]></category>
		<category><![CDATA[XMLListCollection]]></category>
		<category><![CDATA[filterFunction]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[test()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/04/01/filtering-an-xmllistcollection-using-regular-expressions/</guid>
		<description><![CDATA[<p>The following example shows how you can filter an XMLListCollection collection by using regular expressions in Flex 4.</p> <p>Full code after the jump.</p> <p></p> <p>For more information on the the API changes related to the removal of the &#8220;fx&#8221; prefix in Flex 4, see the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Dropping+the+Fx+Prefix">&#8220;Dropping the Fx Prefix&#8221;</a> page on opensource.adobe.com.</p> &#60;?xml version=&#34;1.0&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can filter an XMLListCollection collection by using regular expressions in Flex 4.</p>
<p>Full code after the jump.</p>
<p><span id="more-1035"></span></p>
<p class="alert">The following example(s) require Flash Player 10 and the Adobe Flex 4 SDK. To download the Adobe Flash Builder 4 trial, see <a href="http://bit.ly/crThlI">http://www.adobe.com/products/flex/</a>. To download the latest nightly build of the Flex 4 SDK, see <a href="http://bit.ly/Flex4SDK">http://opensource.adobe.com/wiki/display/flexsdk/Download+Flex+4</a>.<br/><strong>For more information on getting started with Flex 4 and Flash Builder 4, see the official <a href="http://bit.ly/dCkecm">Adobe Flex Team blog</a>.</strong></p>
<p>For more information on the the API changes related to the removal of the &#8220;fx&#8221; prefix in Flex 4, see the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Dropping+the+Fx+Prefix">&#8220;Dropping the Fx Prefix&#8221;</a> page on opensource.adobe.com.</p>

<div class="wp_syntax"><div class="code"><pre class="mxml" style="font-family:monospace;"><span style="color: #000000;">&lt;?xml version=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #7400FF;">&gt;</span></span>
<span style="color: #000000;"><span style="color: #808080; font-style: italic;">&lt;!-- http://blog.flexexamples.com/2009/04/01/filtering-an-xmllistcollection-using-regular-expressions/ --&gt;</span></span>
<span style="color: #000000;"><span style="color: #7400FF;">&lt;s:Application</span> name=<span style="color: #ff0000;">&quot;XMLListCollection_filterFunction_RegExp_test&quot;</span></span>
<span style="color: #000000;">        xmlns:fx=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #000000;">        xmlns:s=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #000000;">        xmlns:mx=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/mx&quot;</span></span>
<span style="color: #000000;">        backgroundColor=<span style="color: #ff0000;">&quot;white&quot;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:layout</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:VerticalLayout</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:layout</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;">&lt;!<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span></span>
<span style="color: #000000;">            private function textInput_change<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>:void <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                if <span style="color: #66cc66;">&#40;</span>textInput.text.length == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    xmlListColl.filterFunction = null;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span> else <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                    xmlListColl.filterFunction = xmlListColl_filterFunc;</span>
<span style="color: #000000;">                <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">                xmlListColl.refresh<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
&nbsp;
<span style="color: #000000;">            private function xmlListColl_filterFunc<span style="color: #66cc66;">&#40;</span>item:Object<span style="color: #66cc66;">&#41;</span>:Boolean <span style="color: #66cc66;">&#123;</span></span>
<span style="color: #000000;">                if <span style="color: #66cc66;">&#40;</span>textInput.text.length == <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> return true;</span>
<span style="color: #000000;">                var f:String = <span style="color: #ff0000;">&quot;ig&quot;</span>;</span>
<span style="color: #000000;">                var wasRegExp:RegExp = new RegExp<span style="color: #66cc66;">&#40;</span>textInput.text, f<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                var nowRegExp:RegExp = new RegExp<span style="color: #66cc66;">&#40;</span>textInput.text, f<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                var wasMatch:Boolean = wasRegExp.test<span style="color: #66cc66;">&#40;</span>item.@was<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">                var nowMatch:Boolean = nowRegExp.test<span style="color: #66cc66;">&#40;</span>item.@now<span style="color: #66cc66;">&#41;</span>;</span>
&nbsp;
<span style="color: #000000;">                return <span style="color: #66cc66;">&#40;</span>wasMatch || nowMatch<span style="color: #66cc66;">&#41;</span>;</span>
<span style="color: #000000;">            <span style="color: #66cc66;">&#125;</span></span>
<span style="color: #000000;">        <span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Script</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;fx:XML</span> id=<span style="color: #ff0000;">&quot;nodesXML&quot;</span> source=<span style="color: #ff0000;">&quot;nodes.xml&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:XMLListCollection</span> id=<span style="color: #ff0000;">&quot;xmlListColl&quot;</span></span>
<span style="color: #000000;">                source=<span style="color: #ff0000;">&quot;{nodesXML.node}&quot;</span></span>
<span style="color: #000000;">                filterFunction=<span style="color: #ff0000;">&quot;xmlListColl_filterFunc&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/fx:Declarations</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:Form</span> styleName=<span style="color: #ff0000;">&quot;plain&quot;</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:FormItem</span> label=<span style="color: #ff0000;">&quot;Filter:&quot;</span><span style="color: #7400FF;">&gt;</span></span>
                <span style="color: #000000;"><span style="color: #7400FF;">&lt;s:TextInput</span> id=<span style="color: #ff0000;">&quot;textInput&quot;</span></span>
<span style="color: #000000;">                        change=<span style="color: #ff0000;">&quot;textInput_change();&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:FormItem</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:Form</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:controlBarContent</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGrid</span> id=<span style="color: #ff0000;">&quot;dataGrid&quot;</span></span>
<span style="color: #000000;">            dataProvider=<span style="color: #ff0000;">&quot;{xmlListColl}&quot;</span></span>
<span style="color: #000000;">            verticalScrollPolicy=<span style="color: #ff0000;">&quot;on&quot;</span></span>
<span style="color: #000000;">            width=<span style="color: #ff0000;">&quot;90%&quot;</span></span>
<span style="color: #000000;">            rowCount=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #7400FF;">&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:columns</span><span style="color: #7400FF;">&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> dataField=<span style="color: #ff0000;">&quot;@was&quot;</span> headerText=<span style="color: #ff0000;">&quot;Was:&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
            <span style="color: #000000;"><span style="color: #7400FF;">&lt;mx:DataGridColumn</span> dataField=<span style="color: #ff0000;">&quot;@now&quot;</span> headerText=<span style="color: #ff0000;">&quot;Now:&quot;</span> <span style="color: #7400FF;">/&gt;</span></span>
        <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:columns</span><span style="color: #7400FF;">&gt;</span></span>
    <span style="color: #000000;"><span style="color: #7400FF;">&lt;/mx:DataGrid</span><span style="color: #7400FF;">&gt;</span></span>
&nbsp;
<span style="color: #000000;"><span style="color: #7400FF;">&lt;/s:Application</span><span style="color: #7400FF;">&gt;</span></span></pre></div></div>

<p>And the <em>nodes.xml</em> data file is as follows:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/04/01/filtering-an-xmllistcollection-using-regular-expressions/ --&gt;
&lt;nodes&gt;
    &lt;node was="mx.components.ButtonBarButton" now="spark.components.ButtonBarButton" /&gt;
    &lt;node was="mx.components.DataGroup" now="spark.components.DataGroup" /&gt;
    &lt;node was="mx.components.DropDownList" now="spark.components.DropDownList" /&gt;
    &lt;node was="mx.components.FxButton" now="spark.components.Button" /&gt;
    &lt;node was="mx.components.FxButtonBar" now="spark.components.ButtonBar" /&gt;
    &lt;!-- ... --&gt;
&lt;/nodes&gt;
</pre>
<div span="googleAdsLeaderboard">
<script type="text/javascript"><!--
google_ad_client = "pub-3325829455487492";
/* 728x90, created 7/15/09 */
google_ad_slot = "6403511741";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<br />
</div>
<p class="information"><a href="http://dl.dropbox.com/u/4509565/FlexExamples_com/XMLListCollection_filterFunction_RegExp_test/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://dl.dropbox.com/u/4509565/FlexExamples_com/XMLListCollection_filterFunction_RegExp_test/main.html" width="100%" height="400"></iframe></p>
<p class="alert">This entry is based on a beta version of the Flex 4 SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex 4 SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Filtering an XMLListCollection using Regular Expressions on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/04/01/filtering-an-xmllistcollection-using-regular-expressions/',contentID: 'post-1035',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'filterFunction,Gumbo,test()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2009/04/01/filtering-an-xmllistcollection-using-regular-expressions/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using a Slider to filter items in a DataGrid control in Flex</title>
		<link>http://blog.flexexamples.com/2008/09/12/using-a-slider-to-filter-items-in-a-datagrid-control-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/09/12/using-a-slider-to-filter-items-in-a-datagrid-control-in-flex/#comments</comments>
		<pubDate>Sat, 13 Sep 2008 06:57:41 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[HSlider]]></category>
		<category><![CDATA[filterFunction]]></category>
		<category><![CDATA[refresh()]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/09/12/using-a-slider-to-filter-items-in-a-datagrid-control-in-flex/</guid>
		<description><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/">&#8220;Using a CheckBox to filter items in a DataGrid in Flex&#8221;</a>, we saw how to filter the items in a Flex DataGrid control based on whether the user selected a CheckBox control or not.</p> <p>The following example shows how you can filter items in a Flex DataGrid control using an [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous example, <a href="http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/">&#8220;Using a CheckBox to filter items in a DataGrid in Flex&#8221;</a>, we saw how to filter the items in a Flex DataGrid control based on whether the user selected a CheckBox control or not.</p>
<p>The following example shows how you can filter items in a Flex DataGrid control using an HSlider control, and the ArrayCollection class’s <code>filterFunction</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-747"></span></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/09/12/using-a-slider-to-filter-items-in-a-datagrid-control-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"
        creationComplete="init();"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.SliderEvent;

            private function init():void {
                if (checkBox.selected) {
                    arrColl.filterFunction = sliderFilterFunc;
                    arrColl.refresh();
                }
            }

            private function checkBox_change(evt:Event):void {
                if (checkBox.selected) {
                    arrColl.filterFunction = sliderFilterFunc;
                } else {
                    arrColl.filterFunction = null;
                }
                arrColl.refresh();
            }

            private function slider_change(evt:SliderEvent):void {
                arrColl.refresh();
            }

            private function sliderFilterFunc(item:Object):Boolean {
                var minSlider:uint = slider.values[0];
                var maxSlider:uint = slider.values[1];
                if ((item.value &gt;= minSlider) &#038;&#038;
                            (item.value &lt;= maxSlider)) {
                    return true;
                } else {
                    return false;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ArrayCollection id="arrColl"&gt;
        &lt;mx:source&gt;
            &lt;mx:Array&gt;
                &lt;mx:Object label="One" value="100" /&gt;
                &lt;mx:Object label="Two" value="2" /&gt;
                &lt;mx:Object label="Three" value="300" /&gt;
                &lt;mx:Object label="Four" value="40" /&gt;
                &lt;mx:Object label="Five" value="500" /&gt;
                &lt;mx:Object label="Six" value="60" /&gt;
                &lt;mx:Object label="Seven" value="700" /&gt;
                &lt;mx:Object label="Eight" value="800" /&gt;
                &lt;mx:Object label="Nine" value="90" /&gt;
                &lt;mx:Object label="Ten" value="100" /&gt;
            &lt;/mx:Array&gt;
        &lt;/mx:source&gt;
    &lt;/mx:ArrayCollection&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:Form styleName="plain"&gt;
            &lt;mx:FormItem label="filter:"&gt;
                &lt;mx:CheckBox id="checkBox"
                        selected="true"
                        change="checkBox_change(event);" /&gt;
            &lt;/mx:FormItem&gt;
            &lt;mx:FormItem label="values:"&gt;
                &lt;mx:HSlider id="slider"
                        minimum="0"
                        maximum="1000"
                        values="[0,1000]"
                        labels="[0,500,1000]"
                        thumbCount="2"
                        showTrackHighlight="true"
                        snapInterval="1"
                        tickInterval="100"
                        liveDragging="true"
                        change="slider_change(event);" /&gt;
            &lt;/mx:FormItem&gt;
        &lt;/mx:Form&gt;
    &lt;/mx:ApplicationControlBar&gt;

    &lt;mx:Panel status="{arrColl.length}/{arrColl.source.length} item(s)"&gt;
        &lt;mx:DataGrid id="dataGrid"
                dataProvider="{arrColl}"
                verticalScrollPolicy="on" /&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using a Slider to filter items in a DataGrid control in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/09/12/using-a-slider-to-filter-items-in-a-datagrid-control-in-flex/',contentID: 'post-747',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'filterFunction,refresh()',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/09/12/using-a-slider-to-filter-items-in-a-datagrid-control-in-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using a CheckBox to filter items in a DataGrid in Flex</title>
		<link>http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/</link>
		<comments>http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/#comments</comments>
		<pubDate>Thu, 13 Mar 2008 02:42:18 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[ArrayCollection]]></category>
		<category><![CDATA[DataGrid]]></category>
		<category><![CDATA[filterFunction]]></category>
		<category><![CDATA[length]]></category>
		<category><![CDATA[refresh()]]></category>
		<category><![CDATA[source]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/</guid>
		<description><![CDATA[<p>The following example shows how you can filter items in a Flex DataGrid using a CheckBox control, and the ArrayCollection class&#8217;s filterFunction property.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ArrayCollection_filterFunction_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:Script&#62; &#60;![CDATA[ import mx.controls.dataGridClasses.DataGridColumn; private function toggleFilter():void { if (checkBox.selected) { [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can filter items in a Flex DataGrid using a CheckBox control, and the ArrayCollection class&#8217;s <code>filterFunction</code> property.</p>
<p>Full code after the jump.</p>
<p><span id="more-560"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/ArrayCollection_filterFunction_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.controls.dataGridClasses.DataGridColumn;

            private function toggleFilter():void {
                if (checkBox.selected) {
                    arrColl.filterFunction = processFilter;
                } else {
                    arrColl.filterFunction = null;
                }
                arrColl.refresh();
            }

            private function processFilter(item:Object):Boolean {
                return parseFloat(item.value) == 0;
            }

            private function value_labelFunc(item:Object, col:DataGridColumn):String {
                return item[col.dataField].toFixed(2);
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:ArrayCollection id="arrColl"&gt;
        &lt;mx:source&gt;
            &lt;mx:Array&gt;
                &lt;mx:Object name="ColdFusion" value="0.00" /&gt;
                &lt;mx:Object name="Dreamweaver" value="0.12" /&gt;
                &lt;mx:Object name="Fireworks" value="1.01" /&gt;
                &lt;mx:Object name="Flash" value="0" /&gt;
                &lt;mx:Object name="Flash Player" value="-0.00" /&gt;
                &lt;mx:Object name="Flex" value="0.00" /&gt;
                &lt;mx:Object name="Illustrator" value="2.92" /&gt;
                &lt;mx:Object name="Lightroom" value="0.32" /&gt;
                &lt;mx:Object name="Photoshop" value="0.06" /&gt;
            &lt;/mx:Array&gt;
        &lt;/mx:source&gt;
    &lt;/mx:ArrayCollection&gt;

    &lt;mx:Panel status="{arrColl.length}/{arrColl.source.length} item(s)"&gt;
        &lt;mx:DataGrid id="dataGrid"
                dataProvider="{arrColl}"
                verticalScrollPolicy="on"&gt;
            &lt;mx:columns&gt;
                &lt;mx:DataGridColumn dataField="name" /&gt;
                &lt;mx:DataGridColumn dataField="value"
                        labelFunction="value_labelFunc" /&gt;
            &lt;/mx:columns&gt;
        &lt;/mx:DataGrid&gt;
        &lt;mx:ControlBar&gt;
            &lt;mx:CheckBox id="checkBox"
                    label="Filter DataGrid"
                    click="toggleFilter();" /&gt;
        &lt;/mx:ControlBar&gt;
    &lt;/mx:Panel&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/ArrayCollection_filterFunction_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/ArrayCollection_filterFunction_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Using a CheckBox to filter items in a DataGrid in Flex on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/',contentID: 'post-560',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'filterFunction,length,refresh(),source',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/03/12/using-a-combobox-to-filter-items-in-a-datagrid-in-flex/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
	</channel>
</rss>

