2 Replies Latest reply on May 28, 2010 10:13 AM by EWN-CMI

    IList - Keeping 2 list ordered?

    EWN-CMI Level 1

      On a component I have 2 list (left, right).  User clicks on left list, get added to right list and removed from left list. User can double-click on right list to remove and the item get added back to the left list - on the bottom.  Think shopping cart, where the left list are items for sale and the right list are items to buy.


      The application displays a list of orders and the above component.  When the user clicks on an order - the component right list gets populated from that order.   Then from the right list, I loop through my master list and remove any items that are in the right list - this becomes the dataProvider for my left list.  Logically, I think all is working OK, but the leftList does not refresh after modifying the dataProvider.  If I use the application dataGrid CHANGE event to reload the master list, I can see (briefly) that the leftList dataProvider looks correct and then the left list updates to the master list.  I have tried to invalidate everything, without success.


      The goal - I would like some repeatability on checkout, I want Item1 to be Item1 in the Left list if it is not already in the right List.  All help is appreciated.


                  public function refreshList() : void
                     var words1:Array = SQLstring.split(" ");       
                     var words2:Array = words1[1].split(",");   //parse my stored query for this order
                     var l1:Array=new Array;                        
                     moveAllItems(rightList, leftList);               //clear out the right list - moves everything to left list, but puts items on right list at the bottom of left list
                     leftListDP= masterList;                         //reset leftList.dataProvider to master -  I don't see this happening?
                      for ( var i:int = 0; i < words.length; i++ ) {  //for each item in order
                     var gData:Object = leftList.dataProvider;    
                           for (var f:int=0; f < gData.length; f++)     //loop through master list to find it
                          {     var thisObj:Object = gData.getItemAt(f);
                               if (thisObj.fieldname == words[i])
                                  l1.push(thisObj);                         //if found the add to right list temp array
                                  f = gData.length;                           
                      rightList.dataProvider=l1;                         //once complete update the right list  - all this works fine


      //REMOVE right list items from left list - seems to only show a change one or at most 2 times in changing the order??

      //but if changing the order goes back to the database on CHANGE event then it always looks like it is working until it gets overwritten


                      for ( var x:int = 0; x < words.length; x++ ) {
                     var gData2:Object = masterList;               //start with master list
                           for (var y:int=0; y < gData2.length; y++)
                          {     var thisObj2:Object = gData2.getItemAt(y);
                               if (thisObj2.fieldname == words[x])





              left="270" top="63" bottom="41"
              change="moveItems(leftList, rightList);">

        • 1. Re: IList - Keeping 2 list ordered?
          BhaskerChari Level 4



          Try to use the refresh() methos on ArrayCollection as and when your ArrayCollection is chnaged or updated as below.


          leftListDP= masterList;



          Try to use the same for all ArrayCollection which you are using as DataProviders for List.


          Try this and let me know if this problem still exists.


          If this post answers your question or helps, please kindly mark it as such.


          Bhasker Chari

          • 2. Re: IList - Keeping 2 list ordered?
            EWN-CMI Level 1

            Thanks for the reply, I was able to fix it by changing my approach.  I now build the left and right list in the app and pass them to the component. I briefly tried the refresh() but it did not keep the list updated like I needed.  But closing this one out and since you were the only one to answer you are correct.