Two things: 
 - Try stuffing the raw XML into a TextArea to see what it looks like.
You could bind it directly to the ADG without first converting to
array/arraycollection; that's the beauty of the e4x format you're
using on the HTTPService call. Not sure why you're doing the
conversion to an array and then to an arraycollection. If you need to
modify the values when they're displayed, try using the labelFunction
on each column. 
 - When I run into issues in code, I try to make it as simple as
possible, make sure that works, then add the additional pieces back in
one by one until I can see what's causing it to act funny. 

I'm thinking something's not quite right with the data after you
manipulate it. Look at that piece.

-Alex

--- In flexcoders@yahoogroups.com, "todd.bruner" <[EMAIL PROTECTED]> wrote:
>
> Hello and thanks in advance for any help you can provide this flex
> newbie.
> 
> I'm trying to create a simple AdvancedDataGrid that displays XML data
> from a web service I wrote.  The XML file looks like:
> 
> <dashboard>
>      <rollup>
>         <period>2008-12-03 01:00:00</period>
>         <period_sse>1228266000</period_sse>
>         <country>
>             <ccode>PH</ccode>
>             <detects>1</detects>
>         </country>
>         <country>
>              <ccode>GB</ccode>
>              <detects>50</detects>
>         </country>
>      </rollup>
>      <rollup>
>           <period>2008-12-04 03:00:00</period>
>           <period_sse>1228359600</period_sse>
>           <country>
>                <ccode>PH</ccode>
>                <detects>18</detects>
>           </country>
>      </rollup>
> </dashboard>
> 
> My Flex 3  MXML app is:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute"
>      creationComplete="init()">
>      <mx:Script>
>          <![CDATA[
>          import mx.collections.ArrayCollection;
>          import mx.rpc.events.ResultEvent;
>          import mx.rpc.events.FaultEvent;
>          import mx.controls.Alert;
> 
>          [Bindable] public var dataServiceURL:String =
> "http://dashboard-dev/cgi-bin/dataService.pl?type=countrystats";;
>          [Bindable] public var chartValues:ArrayCollection;
> 
>          public function init():void
>          {
>              countries_rpc.send();
>          }
>          public function handle_xml(event:ResultEvent):void
>          {
>              var xmlData:XML = event.result as XML;
>              var newData:Array = parseXmlToArray(xmlData);
>              chartValues = new ArrayCollection(newData);
>           }
> 
>          public function handle_fault(event:FaultEvent):void
>          {
>              Alert.show(event.fault.faultString, "Error");
>          }
> 
>          private function parseXmlToArray(xmlData:XML):Array
>          {
>              var newData:Array = new Array();
> 
>              for each (var rollup:XML in xmlData.rollup) {
>                  var carray:Array = new Array();
>                  for each (var country:XML in rollup.country) {
>                      carray.push({
>                          ccode: country.ccode,
>                          detects: country.detects
>                      });
>                  }
>                  carray.sortOn("ccode");
>                  newData.push({
>                      period: rollup.period,
>                      period_msse: rollup.period_sse*1000,
>                      children: carray
>                  });
>              }
>              newData.sortOn("period_msse");
>              return newData;
>          }
>          ]]>
>      </mx:Script>
>      <mx:HTTPService id="countries_rpc" url="{dataServiceURL}"
>        result="handle_xml(event);" fault="handle_fault(event);"
> resultFormat="e4x" />
> 
>      <mx:AdvancedDataGrid id="countrystatgrid" width="50%" height="50%">
>          <mx:dataProvider>
>              <mx:HierarchicalData source="{chartValues}"  />
>          </mx:dataProvider>
>          <mx:columns>
>              <mx:AdvancedDataGridColumn dataField="period" />
>              <mx:AdvancedDataGridColumn dataField="ccode" />
>              <mx:AdvancedDataGridColumn dataField="detects" />
>          </mx:columns>
>      </mx:AdvancedDataGrid>
> </mx:Application>
> 
> When I run this the AdvancedDataGrid is displayed but no data is shown. 
> In the debugger, I can see chartValues and the data from the webservice
> appears to be correctly stuffed into it.
> 
> Can anyone point me in the right direction? Thanks!
> Todd
>


Reply via email to