`
maloveqiao
  • 浏览: 99859 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

Flex ArrayCollection 之排序

    博客分类:
  • flex
 
阅读更多
利用ArrayCollection的sort属性

    <?xml version="1.0" encoding="utf-8"?> 
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"> 
         <mx:Script> 
             <![CDATA[ 
                import mx.collections.SortField; 
                import mx.collections.Sort; 
                import mx.collections.ArrayCollection; 
                private var acSort:ArrayCollection= 
                new ArrayCollection([{id:0,userName:"zhangSan",age:21}, 
                                     {id:2,userName:"liSi",age:24}, 
                                     {id:1,userName:"wangWu",age:31}]); 
                 
                 
                private function sortAc():ArrayCollection{ 
                     var sort:Sort=new Sort(); 
                    //按照ID升序排序 
                     sort.fields=[new SortField("id")]; 
                     
                    //按照userName降序排序 
                     sort.fields=[new SortField("userName",true,true)]; 
                     
                    //先按ID升序,再按userName降序 
                     sort.fields[new SortField("id"),new SortField("userName",true,true)]; 
                     acSort.sort=sort; 
                     acSort.refresh();//更新 
                    return acSort; 
                 } 
                 
             
             ]]> 
         </mx:Script> 
    </mx:Application>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics