5 Replies Latest reply on Oct 26, 2006 1:49 PM by SoffwurAppDev

    store data from a dataGrid into an Array

    ljonny18 Level 1

      I want to take all of the data from an "editable" dataGrid within my Flex 2 application and store / put the data into an array, and then send it to a webService where it is eventually inserted into a DB etc......
      I am currently having trouble taking the data from the dataGrid and putting / storing it in an array.

      so far..........

      I have populated a dataGrid using a webService..... :

      <mx:WebService id="wsData" wsdl=" http://.......cfc?wsdl" load="wsData.populateDG();">
      <mx:operation name="populateDG" result="handleWSR_populateDG(event)"/>

      I then set a [bindable] as an object and assign the results from the webService to the created variable.... :

      public var DG_Provider:Object;

      public function handleWSR_populateDG(event:ResultEvent):void
      DG_Provider= event.result;

      and I am then populating my dataGrid with this formed "result" ... :

      <mx:DataGrid id="dg" editable="true" dataProvider="{DG_Provider}">
      <mx:DataGridColumn id="a" dataField="a" headerText="a"/>
      <mx:DataGridColumn id="b" dataField="b" headerText="b"/>
      <mx:DataGridColumn id="c" dataField="c" headerText="c"/>
      <mx:DataGridColumn id="d" dataField="d" headerText="d"/>


      the reason I set my "results" variable as an object was purely because that is how it was said to do in a tutorial I was following.... if I try to change it from and "Object" to either an "Array" or "ArrayCollection" etc... I get the error ... :

      "Implicit coercion of a value with static type Object to a possibly unrelated type Array" ...

      is there a way that I can store the data from the dataGrid and put them into an Array for sending to a webService.

      Any suggestions would be much appreciated,