4 Replies Latest reply on Feb 3, 2010 11:57 AM by PeakDigital

    Sorting then adding an item

    Francisc Level 3



      I have an AC with names.

      I want to sort it everytime a name changes but keep as the first item "Select name" as I use it for a ComboBox.


      What I do and does not work is this:


      public function sortAC():void


           myAC.removeItemAt(0);//Remove the "Select name" item so I can sort and add it at the end again.


           var dataSortField:SortField=new SortField();



           var dataSort:Sort=new Sort();





           myAC.addItemAt({'id':0,'name':'Select Name''},0);//add the top value again after sorting and refreshing



      The problem is "Select Name" gets placed alphabetically in the list as it should if sorted.


      How can I keep it on top and still sort please?


      Thank you!