2 Replies Latest reply on Aug 30, 2007 1:02 PM by RManNJ

    .NET WS -> Collection -> DataGrid does not work

    RManNJ
      Hi there.
      Does anyone have a working example of .NET Web Service Flex consumer with storing WS results in ArrayCollection or XMLCollection to be used in DataGrid? It seems like I tried everything out there - still no luck. In my code below 2 datagrids, dg1 binded to myAC variable and dg2 binded directly to WS. dg2 works fine, dg1 does not.
      Thanks for help.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="Data_WS.getRegions();">
      <mx:WebService result="onResult(event)" id="Data_WS" wsdl=" http://localhost/myWSSite/Data_WS.asmx?WSDL" useProxy="false" showBusyCursor="true">
      <mx:operation name="getRegions" >
      </mx:operation>
      </mx:WebService>
      <mx:Script>
      <![CDATA[
      import mx.rpc.events.ResultEvent;
      import mx.utils.ArrayUtil;
      import mx.controls.Alert;
      import mx.collections.*;

      [Bindable] public var myAC:XMLListCollection;

      public function onResult(resultEvent:ResultEvent):void
      {
      myAC = new XMLListCollection(XMLList(resultEvent.result.ArrayOfCRegion));
      trace(myAC);
      trace(myAC.length);
      }
      ]]>
      </mx:Script>
      <mx:Panel x="10" y="10" width="661" height="499" layout="absolute" title="Testing Crap...">
      <mx:Button x="122.5" y="374" label="Button" click="init();"/>
      <mx:DataGrid x="10" y="10" id="dg1" width="290" height="150" dataProvider="{myAC}">
      <mx:columns>
      <mx:DataGridColumn headerText="Code" dataField="Code"/>
      <mx:DataGridColumn headerText="Description" dataField="Description"/>
      </mx:columns>
      </mx:DataGrid>

      <mx:DataGrid x="10" y="168" id="dg2" width="290" height="150" dataProvider="{Data_WS.getRegions.lastResult}" >
      <mx:columns>
      <mx:DataGridColumn headerText="Code" dataField="Code"/>
      <mx:DataGridColumn headerText="Description" dataField="Description"/>
      </mx:columns>
      </mx:DataGrid>
      </mx:Panel>
      </mx:Application>

      . NET Web Service result
      <?xml version="1.0" encoding="utf-8" ?>
      - <ArrayOfCRegion xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd=" http://www.w3.org/2001/XMLSchema" xmlns=" http://ml.com/Phoenix/">
      - <CRegion>
      <Code>00</Code>
      <Description>-- All Regions --</Description>
      </CRegion>
      - <CRegion>
      <Code>01</Code>
      <Description>U.S.</Description>
      </CRegion>
      - <CRegion>
      <Code>02</Code>
      <Description>JAPAN</Description>
      </CRegion>
      </ArrayOfCRegion>

      .NET WSDL fragment
      - <s:element name="getRegions">
      <s:complexType />
      </s:element>
      - <s:element name="getRegionsResponse">
      - <s:complexType>
      - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="getRegionsResult" type="tns:ArrayOfCRegion" />
      </s:sequence>
      </s:complexType>
      </s:element>
      - <s:complexType name="ArrayOfCRegion">
      - <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="CRegion" nillable="true" type="tns:CRegion" />
      </s:sequence>
      </s:complexType>
      - <s:complexType name="CRegion">
      - <s:sequence>
      <s:element minOccurs="0" maxOccurs="1" name="Code" type="s:string" />
      <s:element minOccurs="0" maxOccurs="1" name="Description" type="s:string" />
      </s:sequence>
      </s:complexType>