2 Replies Latest reply on Sep 13, 2009 6:02 PM by Marlene

    Access to data information in list component

    Marlene Level 1

      I have attached a screenshot of the information Ineed to "get at". I am still relatively new to Flex and I have a total disconnect about which code to use so I have tried all kinds of properties and functions. Now I am really confused. I want the user to be able to remove any of the restaurants and then email the list to themselves. The listComponent ID is favoritesList. The dataProvider comes from a drag-drop operation from a datagrid. The dataProvider for the datagrid was an arrayCollection with an id of restaruatnsAC.

       

      thanks

        • 1. Re: Access to data information in list component
          joeroth2010 Level 1

          This trick is creating a second, empty, ArrayCollection which is databound to the drop-enabled list.  When you want to do anything to the items in that list, you simply work with that 2nd ArrayCollection.  Heres some code:

           

          <?xml version="1.0"?>

           

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"   xmlns:ns1="*">

           

          <mx:Script>

           

          <![CDATA[

           

          import mx.collections.ArrayCollection;

           

          [Bindable]

           

          private var ac:ArrayCollection = new ArrayCollection([

           

          {restaurant: 'Restaurant 1'},

           

          {restaurant: 'Restaurant 2'},

           

          {restaurant: 'Restaurant 3'},

           

          {restaurant: 'Restaurant 4'}

           

          ]);

           

          [Bindable]
          private var ac2:ArrayCollection = new ArrayCollection();

           

          private function removeSelected():void{
              ac2.removeItemAt(chosenList.selectedIndex);
          }

           


          ]]>
          </mx:Script>

           

          <mx:DataGrid dataProvider="{ac}" dragEnabled="true">
              <mx:columns>
                  <mx:DataGridColumn headerText="Restaurant" dataField="restaurant"/>
              </mx:columns>
          </mx:DataGrid>

           

          <mx:DataGrid id="chosenList" dataProvider="{ac2}" dropEnabled="true">
              <mx:columns>
                  <mx:DataGridColumn headerText="Restaurant" dataField="restaurant"/>
              </mx:columns>
          </mx:DataGrid>

           

          <mx:Button label="Remove Selected" click="removeSelected()"/>

           

          </mx:Application>

           

           

           

           

          Hope this helps.

           

          Joe

          • 2. Re: Access to data information in list component
            Marlene Level 1

            Thank you. Your answer was very helpful!