true, true... guess I assumed the OP had some reason for wanting to use DG. Column headers etc.
Scott Scott Melby Founder, Fast Lane Software LLC http://www.fastlanesw.com http://blog.fastlanesw.com Alex Harui wrote: > Or just use List. > > > > ________________________________ > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of Scott Melby > Sent: Tuesday, March 25, 2008 4:21 AM > To: flexcoders@yahoogroups.com > Subject: Re: [flexcoders] Re: ArrayCollection of String as single-column > DataGrid provider > > > > You have a couple of choices... you could translate the strings to > objects with a single property (loop over them), then feed that array to > a standard DataGrid. Or, if you plan to be doing a lot of this, you > could create a custom component that does the job internally. It is a > pretty trivial exercise to build a custom data grid that does what you > want. Try the code below to get you started. NOTE: code created in > this editor and may not even compile... but, it'll get you close :) > > This code does not create your column for you etc. Instead it counts on > you to create it in your MXML where you create your StringGrid. Note > however, that you could do that in this class as well... maybe have a > public property for the headerText of the single column, then create the > column internally giving it the headerText from the property and the > dataField of "label" > > public class StringGrid extends DataGrid > { > public override function set dataProvider(value:Object):void > { > var myDP:ArrayCollection = new ArrayCollection(); > if(value is Array) > { > var strArray:Array = Array(value); > for each(var str:String in strArray) > { > var obj:Object = new Object(); > //need to use label in your datagrid column > obj.label = str; > myDP.add(obj); > } > super.dataProvider = myDP > } > else > { > super.dataProvider = value; > } > } > } > > hth > Scott > > Scott Melby > Founder, Fast Lane Software LLC > http://www.fastlanesw.com <http://www.fastlanesw.com> > http://blog.fastlanesw.com <http://blog.fastlanesw.com> > > > > mario.blataric wrote: > > Ok, how do I display and edit ArrayCollection that contains only > String types in it if I can't use DG? > > --- In flexcoders@yahoogroups.com <mailto:flexcoders@yahoogroups.com> , > "Alex Harui" <[EMAIL PROTECTED]> <mailto:[EMAIL PROTECTED]> wrote: > > > You cannot use simple types (String, Number) in a DG. You have > to use > objects like: > > > > <mx:Object label="String1" /> > > > > > > > > > > >