blob: 050287975ac617d144fbd775172dea2b64a85881 [file] [log] [blame]
<?xml version="1.0" encoding="utf-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="100%" height="100%">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
private var _locales:ArrayCollection = new ArrayCollection(['en-US','de-DE','ja-JP','ru-RU','ar-SA','zh-CN']);
private function sortInOrder(order:int):void {
switch (order)
{
case 1:
mySort.fields = [firstField,lastField,ageField];
break;
case 2:
mySort.fields = [lastField,firstField,ageField];
break;
case 3:
mySort.fields = [ageField,firstField,lastField];
break;
case 4:
mySort.fields = [firstField,ageField,lastField];
break;
}
employeeArrColl.sort = mySort;
employeeArrColl.refresh();
}
]]>
</fx:Script>
<fx:Declarations>
<s:Sort id="mySort" locale="{localeCB.selectedItem}"/>
<s:SortField id="firstField" name="first"/>
<s:SortField id="lastField" name="last"/>
<s:SortField id="ageField" name="age"/>
<s:ArrayCollection id="employeeArrColl">
<fx:Object first="Anders" last="Öhlund" age="36"/>
<fx:Object first="Eileen" last="Oehland" age="25"/>
<fx:Object first="Anders" last="Zorn" age="36"/>
<fx:Object first="Steve" last="Aaron" age="40"/>
<fx:Object first="Toren" last="Ohlin" age="20"/>
<fx:Object first="Toren" last="Aaron" age="36"/>
<fx:Object first="Torolf" last="Aaron" age="40"/>
</s:ArrayCollection>
</fx:Declarations>
<s:Panel title="Spark Sort and SortField" width="100%" height="100%">
<s:layout>
<s:HorizontalLayout paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" />
</s:layout>
<s:Form height="100%" width="100%">
<s:Label text="Select a locale to see the strings sorting result:"/>
<s:Spacer height="15"/>
<s:FormItem label="Locale: ">
<s:ComboBox id="localeCB" dataProvider="{_locales}" selectedIndex="0"/>
</s:FormItem>
<s:Label text=" ==========================================================================="/>
<s:FormItem label="Sorting Priority:" toolTip="Click priority radio button to sort multiple columns">
<s:RadioButton id="flaRB" groupName="priority" label="first name > last name > age" click="sortInOrder(1)"/>
<s:RadioButton id="lfaRB" groupName="priority" label="last name > first name > age" click="sortInOrder(2)"/>
<s:RadioButton id="alfRB" groupName="priority" label="age > first name > last name" click="sortInOrder(3)"/>
<s:RadioButton id="falRB" groupName="priority" label="first name > age > last name" click="sortInOrder(4)"/>
</s:FormItem>
<s:FormItem label="Employee Table:" toolTip="Click data grid column header to sort single one column">
<s:DataGrid id="dg" dataProvider="{employeeArrColl}" width="100%">
<s:columns>
<s:ArrayList>
<s:GridColumn dataField="first" headerText="First Name"/>
<s:GridColumn dataField="last" headerText="Last Name"/>
<s:GridColumn dataField="age" headerText="Age"/>
</s:ArrayList>
</s:columns>
</s:DataGrid>
</s:FormItem>
</s:Form>
</s:Panel>
</s:Module>