3 Replies Latest reply on Dec 1, 2008 10:30 AM by Gregory Lafrance

    AdvancedDataGrid with HTTPService

    premadas

      Hi All,
      I have problem with AdvancedDataGrid by using HTTPService.Actually i don't know how to get the data from xml file and display in AdvancedDataGrid but i know how to get the data from xml file and display in DataGrid.

      Here XML file structure is different.......
      How to get and display the data in AdvancedDataGrid.If u have a example please send it to me.

      here am posting my code.....

      MXML code ..................

      <?xml version="1.0"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      creationComplete="salesRequest.send();">
      <mx:Script>
      <![CDATA[
      import mx.collections.XMLListCollection;
      import mx.rpc.events.ResultEvent;

      [Bindable] public var salesDP:XMLListCollection;

      private function salesResultHandler(event:ResultEvent):void{
      salesDP = new XMLListCollection(event.result.Category);
      }
      ]]>
      </mx:Script>
      <mx:HTTPService id="salesRequest" useProxy="false" resultFormat="e4x"
      result="salesResultHandler(event)" url="adg.xml"/>
      <mx:AdvancedDataGrid width="100%" height="100%">
      <mx:dataProvider>
      <mx:HierarchicalData source="{salesDP}"/>
      </mx:dataProvider>
      <mx:columns>
      <mx:AdvancedDataGridColumn dataField="@Category"
      headerText="Category"/>
      <mx:AdvancedDataGridColumn dataField="@Product"
      headerText="Product"/>
      <mx:AdvancedDataGridColumn dataField="@InStock"
      headerText="In Stock"/>
      <mx:AdvancedDataGridColumn dataField="@OnOrder"
      headerText="On Order"/>
      </mx:columns>
      </mx:AdvancedDataGrid>
      </mx:Application>

      XML file........

      <?xml version="1.0″ encoding="utf-8″ ?>
      <Category Category="Poultry">
      <Category Category="Chicken">
      <Product Product="skinless breasts"
      InStock="565 lbs" OnOrder="1000 lbs"/>
      <Product Product="thighs"
      InStock="385 lbs" OnOrder="700 lbs"/>
      <Product Product="nuggets"
      InStock="230 lbs" OnOrder="400 lbs"/>
      </Category>
      <Category Category="Turkey">
      <Product Product="whole turkeys"
      InStock="1565 lbs" OnOrder="2000 lbs"/>
      <Product Product="turkey burger"
      InStock="1365 lbs" OnOrder="1200 lbs"/>
      <Product Product="turkey ham"
      InStock="640 lbs" OnOrder="700 lbs"/>
      </Category>
      </Category>

      Thanks in advance,
      Premadas.