[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-05 Thread oneworld95
I've often had to look at multiple examples to figure out what I need
to do for a project. Here are a few places to try, the first one
having some code that matches your scenario,
 - http://www.adobe.com/devnet/flex/quickstart/accessing_xml_data/
(scroll down for the datagrid example; same thing can be used for the ADG)
 - http://www.adobe.com/devnet/flex/quickstart/httpservice/
 - http://www.bpurcell.org/blog/index.cfm?mode=entryentry=1020
 - http://learn.adobe.com/wiki/display/Flex/2b.+Code+Files

- Alex

--- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote:

 What are you wanting in your display?
 
  
 
 A straight table with three columns: period, ccode, and detects?
 
  
 
 If so, then that is not hierarchical and you are making this more
 complicated than it is.  Why did you choose ADG instead of plain old
 DataGrid?
 
  
 
 If your issue is accessing data nested in subnodes, then use a
 labelFunction.
 
  
 
 Make the dataProvider = xmlData.rollup (an XMLList. If you plan to
 undate it programatically, then wrap it in an XMLListCollection).  The
 labelFunction can reach down into any node of rollup you want
 
  
 
 Tracy
 
 
 
 From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
 Behalf Of todd.bruner
 Sent: Thursday, December 04, 2008 7:06 PM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] Re: Data not appearing in AdvancedDataGrid
 
  
 
 Alex:
 
 Thank you for your suggestions. I stuffed the raw XML into a TextArea
 and it looks fine and matches what I get requesting the same url in my
 web browser.
 
 The reason I'm fussing with array/arraycollection is ignorance. I'm
 trying to adapt things from various examples I've seen. I'm trying to
 do as you suggest bind directly, however, I'm not sure I'm doing that
 right either.
 
 I agree with you about keeping it simple...unfortunately, that's what
 I thought I was doing! :-) 
 
 So given the my xml format, how do I bind it to the ADG? All the
 examples I can find use objects and HeirachicalData. If anyone can
 point me towards an example, I'll take from there.
 
 Thanks!
 
 --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
 , oneworld95 oneworld95@ wrote:
 
  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
 





[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-05 Thread todd.bruner
Alex:

Thanks so much for the links!  I think they will be a tremendous help.

Todd


--- In flexcoders@yahoogroups.com, oneworld95 [EMAIL PROTECTED] wrote:

 I've often had to look at multiple examples to figure out what I need
 to do for a project. Here are a few places to try, the first one
 having some code that matches your scenario,
  - http://www.adobe.com/devnet/flex/quickstart/accessing_xml_data/
 (scroll down for the datagrid example; same thing can be used for
the ADG)
  - http://www.adobe.com/devnet/flex/quickstart/httpservice/
  - http://www.bpurcell.org/blog/index.cfm?mode=entryentry=1020
  - http://learn.adobe.com/wiki/display/Flex/2b.+Code+Files
 
 - Alex
 




[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-05 Thread todd.bruner
Tracy:

Thanks for taking the time to reply.
I was wishing to display something like:

period
 2008-12-5 00:00:00|  |
   |  CK  | 101
   |  US  | 33
   |  UK  | 10
 2008-12-5 01:00:00|  |
   |  PB  | 5
   |  CA  | 14
   |  IT  | 200
...etc...

I will explore your other suggestions below...Thanks!

Todd

--- In flexcoders@yahoogroups.com, Tracy Spratt [EMAIL PROTECTED] wrote:

 What are you wanting in your display?
 
  
 
 A straight table with three columns: period, ccode, and detects?
 
  
 
 If so, then that is not hierarchical and you are making this more
 complicated than it is.  Why did you choose ADG instead of plain old
 DataGrid?
 
  
 
 If your issue is accessing data nested in subnodes, then use a
 labelFunction.
 
  
 
 Make the dataProvider = xmlData.rollup (an XMLList. If you plan to
 undate it programatically, then wrap it in an XMLListCollection).  The
 labelFunction can reach down into any node of rollup you want
 
  
 
 Tracy
 




[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-05 Thread oneworld95
You'd probably want to use a labelFunction on each column where you
want to do something to what the user sees. I think one of the links I
sent you has info on creating labelFunctions. Here's an example,

// As described here: http://thanksmister.com/?p=8
// Pulls data from XML nodes that are optional. 
// Assumes your XML has an element called image that
// has an attribute called id.
public function getImageID(item:Object,
column:AdvancedDataGridColumn):String {
  if (item.image == undefined) {
return null;
  }
  else {
return [EMAIL PROTECTED];
  }
}

In your ADG, you'd call this function like this:

mx:AdvancedDataGridColumn labelFunction=getImageID 
  headerText=Image ID /

-Alex

--- In flexcoders@yahoogroups.com, todd.bruner [EMAIL PROTECTED] wrote:

 Tracy:
 
 Thanks for taking the time to reply.
 I was wishing to display something like:
 
 period
  2008-12-5 00:00:00|  |
|  CK  | 101
|  US  | 33
|  UK  | 10
  2008-12-5 01:00:00|  |
|  PB  | 5
|  CA  | 14
|  IT  | 200
 ...etc...
 
 I will explore your other suggestions below...Thanks!
 
 Todd
 
 --- In flexcoders@yahoogroups.com, Tracy Spratt tspratt@ wrote:
 
  What are you wanting in your display?
  
   
  
  A straight table with three columns: period, ccode, and detects?
  
   
  
  If so, then that is not hierarchical and you are making this more
  complicated than it is.  Why did you choose ADG instead of plain old
  DataGrid?
  
   
  
  If your issue is accessing data nested in subnodes, then use a
  labelFunction.
  
   
  
  Make the dataProvider = xmlData.rollup (an XMLList. If you plan to
  undate it programatically, then wrap it in an XMLListCollection).  The
  labelFunction can reach down into any node of rollup you want
  
   
  
  Tracy
 





[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-05 Thread todd.bruner
I'm starting to make some progress with your help.  I've changed my
xml output and incorporated Alex and Tracy's suggestions.  I can now
see data in the ADG but its not quite what I expected.  Here's the 
what I get:

Period   Country Detects
2008-12-04 03:00:00  PHGBMYDK121341022
2008-12-04 04:00:00  AUGBMY  39211

The Source XML is:
dashboard
 rollup period=2008-12-04 03:00:00
  country code=PH detects=12 /
  country code=GB detects=134 /
  country code=MY detects=102 /
  country code=DK detects=2 /
 /rollup
 rollup period=2008-12-04 04:00:00
...
 /rollup
/dashboard

My MXML fragrements of interest are:

mx:AdvancedDataGrid 
id=myDataGrid
dataProvider={statFeed.rollup}
width=50% 
height=75%
verticalCenter=0 left=0
  mx:AdvancedDataGridColumn headerText=Period  dataField=@period/
  mx:AdvancedDataGridColumn headerText=Country
labelFunction=getCountryCode/
  mx:AdvancedDataGridColumn headerText=Detects
labelFunction=getCountryDetects/
/mx:AdvancedDataGrid

The functions getCountryDetects and getCountryCode are the same as
your label function (changed to appropriate label names.)

What I want is that each rollup period have a spinner that contains
a row for each country that displays the detects during that period.
For example, using the above data:

Period:   Country   Detects
* 2008-12-04 03:00:00
  PH12
  GB134

Many thanks for all the help...
   

--- In flexcoders@yahoogroups.com, oneworld95 [EMAIL PROTECTED] wrote:

 You'd probably want to use a labelFunction on each column where you
 want to do something to what the user sees. I think one of the links I
 sent you has info on creating labelFunctions. Here's an example,
 
 // As described here: http://thanksmister.com/?p=8
 // Pulls data from XML nodes that are optional. 
 // Assumes your XML has an element called image that
 // has an attribute called id.
 public function getImageID(item:Object,
 column:AdvancedDataGridColumn):String {
   if (item.image == undefined) {
 return null;
   }
   else {
 return [EMAIL PROTECTED];
   }
 }
 
 In your ADG, you'd call this function like this:
 
 mx:AdvancedDataGridColumn labelFunction=getImageID 
   headerText=Image ID /
 
 -Alex
 




[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-05 Thread oneworld95
Look up flex itemRenderer on Google. I think that will enable you to
customize the component that displays the rollup column. Within the
itemRenderer, you'd want to do an override of the set data() function. 

-Alex

--- In flexcoders@yahoogroups.com, todd.bruner [EMAIL PROTECTED] wrote:

 I'm starting to make some progress with your help.  I've changed my
 xml output and incorporated Alex and Tracy's suggestions.  I can now
 see data in the ADG but its not quite what I expected.  Here's the 
 what I get:
 
 Period   Country Detects
 2008-12-04 03:00:00  PHGBMYDK121341022
 2008-12-04 04:00:00  AUGBMY  39211
 
 The Source XML is:
 dashboard
  rollup period=2008-12-04 03:00:00
   country code=PH detects=12 /
   country code=GB detects=134 /
   country code=MY detects=102 /
   country code=DK detects=2 /
  /rollup
  rollup period=2008-12-04 04:00:00
 ...
  /rollup
 /dashboard
 
 My MXML fragrements of interest are:
 
 mx:AdvancedDataGrid 
   id=myDataGrid
   dataProvider={statFeed.rollup}
   width=50% 
   height=75%
   verticalCenter=0 left=0
   mx:AdvancedDataGridColumn headerText=Period  dataField=@period/
   mx:AdvancedDataGridColumn headerText=Country
 labelFunction=getCountryCode/
   mx:AdvancedDataGridColumn headerText=Detects
 labelFunction=getCountryDetects/
 /mx:AdvancedDataGrid
 
 The functions getCountryDetects and getCountryCode are the same as
 your label function (changed to appropriate label names.)
 
 What I want is that each rollup period have a spinner that contains
 a row for each country that displays the detects during that period.
 For example, using the above data:
 
 Period:   Country   Detects
 * 2008-12-04 03:00:00
   PH12
   GB134
 
 Many thanks for all the help...

 
 --- In flexcoders@yahoogroups.com, oneworld95 oneworld95@ wrote:
 
  You'd probably want to use a labelFunction on each column where you
  want to do something to what the user sees. I think one of the links I
  sent you has info on creating labelFunctions. Here's an example,
  
  // As described here: http://thanksmister.com/?p=8
  // Pulls data from XML nodes that are optional. 
  // Assumes your XML has an element called image that
  // has an attribute called id.
  public function getImageID(item:Object,
  column:AdvancedDataGridColumn):String {
if (item.image == undefined) {
  return null;
}
else {
  return [EMAIL PROTECTED];
}
  }
  
  In your ADG, you'd call this function like this:
  
  mx:AdvancedDataGridColumn labelFunction=getImageID 
headerText=Image ID /
  
  -Alex
 





[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-05 Thread todd.bruner
I tried something different and got it to work.  Thanks for all your
help.  For others searching, here's what I did. For those following
the thread, if there's a better way to do this, I welcome your
suggestions.  (got the idea to try it this way from Programming Flex
3. Kazoun, Lott)

relevant MXML snippets:

// as code that process the HTTPService return)
private function statResultHandler(event:ResultEvent):void
{
statFeed = event.result as XML;
var statCollection:ArrayCollection = new ArrayCollection;
for each (var rollup:XML in statFeed.children()) {
var period:String = [EMAIL PROTECTED];
for each (var country:XML in rollup.country) {
var code:String = [EMAIL PROTECTED];
var detects:int = [EMAIL PROTECTED];
statCollection.addItem({
rollup: period,
country: code,
quantity: detects
 });
}
}
statGrouping = new GroupingCollection();
statGrouping.source = statCollection;
var grouping:Grouping = new Grouping();
grouping.fields = [new GroupingField(rollup)];
statGrouping.grouping = grouping; 
statGrouping.refresh();
}
 
The ADG mxml:

mx:AdvancedDataGrid 
id=myDataGrid
dataProvider={statGrouping}
width=50% 
height=75%
verticalCenter=0 left=0
mx:groupedColumns
mx:AdvancedDataGridColumn headerText=Period  
dataField=@period/
mx:AdvancedDataGridColumn headerText=Country 
dataField=country/
mx:AdvancedDataGridColumn headerText=Detects 
dataField=quantity/
/mx:groupedColumns
/mx:AdvancedDataGrid


--- In flexcoders@yahoogroups.com, oneworld95 [EMAIL PROTECTED] wrote:

 Look up flex itemRenderer on Google. I think that will enable you to
 customize the component that displays the rollup column. Within the
 itemRenderer, you'd want to do an override of the set data() function. 
 
 -Alex
 




[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-04 Thread oneworld95
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
 period2008-12-03 01:00:00/period
 period_sse1228266000/period_sse
 country
 ccodePH/ccode
 detects1/detects
 /country
 country
  ccodeGB/ccode
  detects50/detects
 /country
  /rollup
  rollup
   period2008-12-04 03:00:00/period
   period_sse1228359600/period_sse
   country
ccodePH/ccode
detects18/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





[flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-04 Thread todd.bruner
Alex:

Thank you for your suggestions.  I stuffed the raw XML into a TextArea
and it looks fine and matches what I get requesting the same url in my
web browser.

The reason I'm fussing with array/arraycollection is ignorance.  I'm
trying to adapt things from various examples I've seen.  I'm trying to
do as you suggest bind directly, however, I'm not sure I'm doing that
right either.

I agree with you about keeping it simple...unfortunately, that's what
I thought I was doing! :-)  

So given the my xml format, how do I bind it to the ADG?  All the
examples I can find use objects and HeirachicalData.  If anyone can
point me towards an example, I'll take from there.

Thanks!

--- In flexcoders@yahoogroups.com, oneworld95 [EMAIL PROTECTED] wrote:

 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
 




RE: [flexcoders] Re: Data not appearing in AdvancedDataGrid

2008-12-04 Thread Tracy Spratt
What are you wanting in your display?

 

A straight table with three columns: period, ccode, and detects?

 

If so, then that is not hierarchical and you are making this more
complicated than it is.  Why did you choose ADG instead of plain old
DataGrid?

 

If your issue is accessing data nested in subnodes, then use a
labelFunction.

 

Make the dataProvider = xmlData.rollup (an XMLList. If you plan to
undate it programatically, then wrap it in an XMLListCollection).  The
labelFunction can reach down into any node of rollup you want

 

Tracy



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of todd.bruner
Sent: Thursday, December 04, 2008 7:06 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Data not appearing in AdvancedDataGrid

 

Alex:

Thank you for your suggestions. I stuffed the raw XML into a TextArea
and it looks fine and matches what I get requesting the same url in my
web browser.

The reason I'm fussing with array/arraycollection is ignorance. I'm
trying to adapt things from various examples I've seen. I'm trying to
do as you suggest bind directly, however, I'm not sure I'm doing that
right either.

I agree with you about keeping it simple...unfortunately, that's what
I thought I was doing! :-) 

So given the my xml format, how do I bind it to the ADG? All the
examples I can find use objects and HeirachicalData. If anyone can
point me towards an example, I'll take from there.

Thanks!

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, oneworld95 [EMAIL PROTECTED] wrote:

 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