Search Flex Components Free

Custom Search

December 27, 2007

Flex Data Collections Sorting (MXML) Sample Source Code:

Sorting.mxml

<?xml version="1.0" encoding="UTF-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="srv.send()">
<mx:ArrayCollection id="airportCollection">
<mx:source>{srv.lastResult.airports.location}</mx:source>
<mx:sort>
<mx:Sort>
<mx:fields>
<mx:Array>
<mx:SortField name="abbreviation" descending="true" />
</mx:Array>
</mx:fields>
</mx:Sort>
</mx:sort>
</mx:ArrayCollection>

<mx:HTTPService id="srv" url="../assets/airports.xml"
result="airportCollection.refresh()" />

<mx:Label text="The items in this datagrid should be in
descending order using the 'abbreviation' field." />
<mx:DataGrid id="dg" dataProvider="{airportCollection}" width="350" />

</mx:Application>

airports.xml
<?xml version="1.0" encoding="utf-8"?>

<airports>
<location>
<abbreviation>IAH</abbreviation>
<name>Houston</name>
</location>
<location>
<abbreviation>BOS</abbreviation>
<name>Boston</name>
</location>
<location>
<abbreviation>MHT</abbreviation>
<name>Houston</name>
</location>
<location>
<abbreviation>JAX</abbreviation>
<name>Jacksonville</name>
</location>
<location>
<abbreviation>CVG</abbreviation>
<name>Cincinatti</name>
</location>
<location>
<abbreviation>ATL</abbreviation>
<name>Atlanta</name>
</location>
<location>
<abbreviation>CDG</abbreviation>
<name>Paris</name>
</location>
<location>
<abbreviation>JFK</abbreviation>
<name>New York</name>
</location>
<location>
<abbreviation>LAX</abbreviation>
<name>Los Angeles</name>
</location>
<location>
<abbreviation>HND</abbreviation>
<name>Tokyo</name>
</location>

</airports>

Related Flex Tutorials