Search Flex Components Free

Custom Search

December 27, 2007

Flex Data Collections Filter Functions With MLListCollections

MLListCollections.mxml

<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundAlpha="0" >

<mx:Script>
<![CDATA[

import mx.collections.*;

private var airportCollection:ArrayCollection;

private function xmlFilterFunc(item:Object):Boolean
{
return
item.@label >= "Inbox" && item.@label <= "Memos";
}

]]>
</mx:Script>

<mx:XML format="e4x" id="source">
<topnode>
<nodes label="Mail" data="mail" />
<nodes label="Inbox" data="inbox" />
<nodes label="Drafts" data="drafts" />
<nodes label="Memos" data="memos" />
<nodes label="Faxes" data="faxes" />
</topnode>
</mx:XML>

<mx:XMLListCollection id="xmlC" source="{source.nodes}" filterFunction="xmlFilterFunc" />

<mx:Label text="A filterFunction is used with an XMLListCollection." />
<mx:Label text="You should only see items from Inbox - Memos." />

<mx:DataGrid id="xmlDG" dataProvider="{xmlC}" >
<mx:columns>
<mx:DataGridColumn dataField="@label" headerText="folders"/>
</mx:columns>
</mx:DataGrid>

</mx:Application>

Related Flex Tutorials