2 Replies Latest reply on Feb 27, 2007 3:30 PM by jfillman

    Is it possible to get all data from a DataGrid

    diegobu
      Is there a way to get all the data from a datagrid?
      I have a datagrid where I can drop data from a second datagrid.
      I would like to send all objects from the datagrid to a web service function

      ---------------
      <mx:DataGrid id="myDataGrid" dropEnabled="true">
      <mx:columns>
      <mx:DataGridColumn dataField="fieldOne"/>
      <mx:DataGridColumn dataField="fieldTwo"/>
      </mx:columns>
      </mx:DataGrid>

      <mx:Button id="myButton" lable="Send" click="ws.sendGridData(myDataGrid.dataProvide}r" />
      ---------

      When I click on the button only the first row is sent to the service.
      Is there a way to send all rows?

      Thanks.
      d.
        • 1. Re: Is it possible to get all data from a DataGrid
          batmitra Level 1
          hi
          in my point of view, you don't send the datagrid items, you send it's dataprovider.
          What i mean is , how do you populate your datagrid? is it with an array of objects? is it with a xml file?
          You need to iterate on the data provider, one by one and send it, or more simply you can send all of them encapsulated on an arraylist but your webservice must know how to read this arraylist.

          • 2. Re: Is it possible to get all data from a DataGrid
            jfillman Level 1
            You can accomplish it this way:

            Set you dataProvider array as a public variable. Then all you have to do is set the dataProvider of the second DataGrid equal to your public array variable.

            For example:

            public var dp:Array= ([{label:"First", data:"25"}, {label:"Second", data:"50"}]);

            public function initApp():void
            {
            testGridOne.dataProvider = dp;
            testGridTwo.dataProvider = [];
            }

            <mx:Button label="Button" click="testGridTwo.dataProvider=dp"/>

            Hope that helps