If you don't specify columns, the DataGrid uses ObjectUtil.getClassInfo to get the list of properties. For XML, getClassInfo returns the attributes and not the child nodes
Alex Harui Flex SDK Developer Adobe Systems Inc.<http://www.adobe.com/> Blog: http://blogs.adobe.com/aharui From: [email protected] [mailto:[email protected]] On Behalf Of Jeffry Houser Sent: Sunday, February 22, 2009 2:24 PM To: [email protected] Subject: Re: [flexcoders] ArrayCollection vs XMLListCollection Some code magic in the background. I bet if you drill down into the component code for DataGrid and/or DataGridColumn you'll find comments that explain this. If I had to guess, it is relatively [knock on wood] easy to parse an object and find the properties on it. I think a for loop will do it. But, XML is much open in terms of "where do I find data" than an ArrayCollection of objects would be. brad.bueche wrote: > How come when I'm setting up a data grid using an ArrayCollection as > the datasource I dont have to specify the contents of the data grid > columns? I can just do this: > > <mx:DataGrid id="dg1" x="42" y="0" width="950" height="100" > dataProvider="{bookData.lastResult.books.stock}" /> > > But in order to get anything to appear on the data grid with either XML > or XMLListCollection I have to do the column layout (like this)? > > <mx:DataGrid id="dg3" x="42" y="300" width="950" height="100" > dataProvider="{bookStock2}" > > <mx:columns> > <mx:DataGridColumn dataField="name" headerText="name"/> > <mx:DataGridColumn dataField="author" headerText="author"/> > <mx:DataGridColumn dataField="category"headerText="category"/> > <mx:DataGridColumn dataField="description" headerText="description"/> > </mx:columns> > </mx:DataGrid> > > Thanks in advance, > brad > > > > ------------------------------------ > > -- > Flexcoders Mailing List > FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt > Alternative FAQ location: > https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847 > Search Archives: > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links > > > > > -- Jeffry Houser, Technical Entrepreneur Adobe Community Expert: http://tinyurl.com/684b5h http://www.twitter.com/reboog711 | Phone: 203-379-0773 -- Easy to use Interface Components for Flex Developers http://www.flextras.com?c=104 -- http://www.theflexshow.com http://www.jeffryhouser.com -- Part of the DotComIt Brain Trust

