4 Replies Latest reply on Jan 31, 2008 11:21 AM by Ratsnackbar

    Combine form fields w/ ArrayCollection

    GeorgeWS Level 1
      I have a datagrid that gets filled from a remote object - ArrayCollection. The Datagrid has a column of checkboxs:

      <mx:DataGrid id="myDataGrid" dataProvider="{myAccounts}" width="100%" height="100%">
      <mx:columns>
      <mx:DataGridColumn headerText="Include" dataField="Include" width="58" sortable="false">

      <mx:itemRenderer>
      <mx:Component>
      <mx:HBox horizontalAlign="center">
      <mx:CheckBox click="data.Include=!data.Include" selected="{data.Include}"/>
      </mx:HBox>
      </mx:Component>
      </mx:itemRenderer>

      </mx:DataGridColumn>
      <mx:DataGridColumn dataField="CUSN05" headerText="Cust" minWidth="45" sortable="false"/>
      <mx:DataGridColumn dataField="DSEQ05" headerText="Seq" minWidth="35" sortable="false"/>
      <mx:DataGridColumn dataField="CAD105" headerText="DBA" minWidth="175" sortable="false"/>
      <mx:DataGridColumn dataField="CAD205" headerText="Address" minWidth="175" sortable="false"/>
      <mx:DataGridColumn dataField="CAD405" headerText="City" minWidth="100" sortable="false"/>
      <mx:DataGridColumn dataField="PCD105" headerText="Zip" width="50" sortable="false"/>
      <mx:DataGridColumn dataField="STTX20" headerText="State" width="50" sortable="false"/>
      <mx:DataGridColumn dataField="PHON05" headerText="Phone" minWidth="100" sortable="false"/>
      <mx:DataGridColumn dataField="SLMN20" headerText="Rep" width="60" sortable="false"/>
      <mx:DataGridColumn dataField="MGRDVP" headerText="Exec" minWidth="100" sortable="false"/>
      </mx:columns>
      </mx:DataGrid>

      I also have some form fields:

      <mx:FormItem id="Item">
      <mx:ComboBox id="item" dataProvider="{myItems}" labelField="label" width="435"/>
      </mx:FormItem>
      <mx:FormItem id="ItemID">
      <mx:TextInput id="itemid" text="{item.selectedItem.data}" visible="false" width="0" includeInLayout="false"/>
      </mx:FormItem>

      I want the user to check some of the checkboxs in the datagrid and press SEND:

      <mx:FormItem id="FI_BTN_send">
      <mx:Button label="Send" click="collectForInclude();sendFormdata()"
      enabled="true" labelPlacement="right"/>
      </mx:FormItem>

      Then the checked records and form fields get merged together and sent to a CFC to insert the records. There should be the same numbers of records inserted as checked in the datagrid. So each record checked should get the form field appended to the record... below the Form field part works and inserts the record using my CFC. The commented part is what im confused.. how do I combine the records so its like..
      ItemID, Item, checked box number 1
      ItemID, Item, checked box number 3
      ItemID, Item, checked box number 4

      private function sendFormdata():void {
      var myobj:Object = new Object();
      myobj.itemid = itemid.text;
      myobj.item = item.selectedLabel;
      cfdataInsert.addData({user:myobj})

      THIS PART I CANNOT GET TO WORK
      //for (var i:int = 0; i < myAccounts.length; i++ ) {
      // var aAccounts:Accounts = myAccounts ;
      // cfdataInsert.update( aAccounts ) ;
      // }
      }

      Any thoughts would be great I hbave been stuck on this for months

      George