1 Reply Latest reply on May 29, 2007 1:06 PM by peterent

    selectedItem, Array Collection won't update after first run.

    jgsstrappy
      Below is a piece of code from a standard ComboBox. The first object in the Array Collection is from an HTTPService return and shows the watershed name that is returned from the database. The other objects in the Array are static on the page and are simply all the other watersheds. The first time that someone runs the form and creates the ArrayCollection the itemSelected (they are double clicking a datagrid to get more details) fills the ComboBox. Now if they go back to the datagrid that has the lastResults, and choose a new selectedItem, the object doesnt change. Can someone explain how I fill that first object with the dynamic piece from the binding of the selectedItem in an ArrayCollection? I read that you need to create a new instance of the ArrayCollection each time a new service is called or itemClick is called, but I am confused how to incorporate only one item into the ArrayCollection and leave the rest alone!

      <mx:ComboBox width="350" id="wsname">
      <mx:ArrayCollection>
      <mx:Object label="{dataPeople.selectedItem.wsname}" data="{dataPeople.selectedItem.wsname}"/>
      <mx:Object label="Auglaize 04100007" data="Auglaize, 04100007"/>
      <mx:Object label="Blue-sinking 05140104" data="Blue-sinking, 05140104"/>
      <mx:Object label="Chicago 07120003" data="Chicago, 07120003"/>
      <mx:Object label="Driftwood 05120204" data="Driftwood, 05120204"/>
      <mx:Object label="Eel (North) 05120104" data="Eel, 05120104 (North) "/>
      /OBJECTS CONTINUE/
      </mx:ArrayCollection>
      </mx:ComboBox>
        • 1. Re: selectedItem, Array Collection won't update after first run.
          peterent Level 2
          I would code this all in ActionScript:

          [Bindable] private var dp:ArrayCollection = new ArrayCollection(
          [ {label:"tbd", data:"tbd"},
          {label:"Auglaise 04100007", data:"Auglaize, 04100007"},
          // etc
          ] );

          <mx:ComboBox dataProvider="{dp}" ... />


          Whenever you want to change the first item, do this:
          var item:Object = dp.getItemAt(0);
          item.label = "new value here";
          item.data = "new value here";
          dp.itemUpdated(item);