| <?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:Application xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx" |
| minWidth="955" minHeight="600" |
| creationComplete="initApp()"> |
| <!-- Sample program for spark.collections.Sort and SortField --> |
| <fx:Script> |
| <![CDATA[ |
| import mx.collections.ArrayCollection; |
| import spark.collections.*; |
| [Bindable] |
| private var collection:ArrayCollection = new ArrayCollection(); |
| |
| private function localeChange():void |
| { |
| // Sets the locale style on this application. |
| // The SortField objects will inherit this style. |
| setStyle('locale', inputLocaleIDName.text); |
| collection.refresh(); |
| } |
| |
| private function initApp() : void |
| { |
| // Add data to the collection. |
| collection.addItem({first:"Anders", last:"Dickerson"}); |
| collection.addItem({first:"Steve", last:"Maccormick"}); |
| collection.addItem({first:"Aiden", last:"MacCormick"}); |
| collection.addItem({first:"Eileen", last:"MacGregor"}); |
| |
| // Create the Sort instance. |
| var sort:Sort = new Sort(); |
| |
| // Set the sort field; sort on the last name first, first name |
| // second. |
| var sortfieldLastName:SortField = new SortField("last",true); |
| var sortfieldFirstName:SortField = new SortField("first",true); |
| sort.fields = [sortfieldLastName, sortfieldFirstName]; |
| |
| // Add the sort field objects to this application's list of |
| // style clients. This will cause the sort field objects to |
| // inherit the locale style from this Application. |
| addStyleClient(sortfieldLastName); |
| addStyleClient(sortfieldFirstName); |
| |
| // Assign the Sort object to the view. |
| collection.sort = sort; |
| |
| // Apply the sort to the collection. |
| collection.refresh(); |
| } |
| ]]> |
| </fx:Script> |
| |
| <s:VGroup> |
| <s:VGroup> |
| <s:HGroup> |
| <s:Label text="Input Locale ID Name: "/> |
| <s:TextInput id="inputLocaleIDName"/> |
| <s:Button click="localeChange()" label="Apply"/> |
| </s:HGroup> |
| <s:Label text="Example: 'en-US', 'fr-FR', 'zh-CN', 'ar-SA'"/> |
| </s:VGroup> |
| |
| <s:DataGrid dataProvider="{collection}" width="100%" |
| creationComplete="{collection.refresh()}"> |
| <s:columns> |
| <s:ArrayList> |
| <s:GridColumn dataField="last"/> |
| <s:GridColumn dataField="first"/> |
| </s:ArrayList> |
| </s:columns> |
| </s:DataGrid> |
| </s:VGroup> |
| </s:Application> |