First, use CreationComplete as Event if you wannt to wait till the Application is ready. After you added your data to the ArrayCollection, you have to call gc.refresh() if you using Groupping in AdvancedDatagrid.
this version works. <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="#32669D" xmlns:ext="nl.wv.extenders.panel.*" width="854" creationComplete="buildData()"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; [Bindable] private var dpFlat:ArrayCollection = new ArrayCollection(); private function buildData():void{ dpFlat = new ArrayCollection([{Region:"Southwest", Territory:"Arizona",Territory_Rep:"Barbara Jennings", Actual:38865,Estimate:40000}, {Region:"Southwest", Territory:"Arizona",Territory_Rep:"Dana Binn", Actual:29885,Estimate:30000}, {Region:"Southwest", Territory:"Central California",Territory_Rep:"Joe Smith", Actual:29134,Estimate:30000}, {Region:"Southwest", Territory:"Nevada",Territory_Rep:"Bethany Pittman", Actual:52888,Estimate:45000}, {Region:"Southwest", Territory:"Northern California",Territory_Rep:"Lauren Ipsum", Actual:38805,Estimate:40000}, {Region:"Southwest", Territory:"Northern California",Territory_Rep:"T.R. Smith", Actual:55498,Estimate:40000}, {Region:"Southwest", Territory:"Southern California",Territory_Rep:"Alice Treu", Actual:44985,Estimate:45000}, {Region:"Southwest", Territory:"Southern California",Territory_Rep:"Jane Grove", Actual:44913,Estimate:45000}]); gc.refresh(); } ]]> </mx:Script> <mx:Panel id="panel04" title="test panel" x="255" y="100" width="100%" height="100%" layout="absolute" > <mx:Label x="15" y="46" text=" Requests in the queue:" width="152" /> <mx:AdvancedDataGrid id="myADG" x="36" y="72" initialize="gc.refresh();" width="520" height="218"> <m<?xml version="1.0" encoding="utf-8"?> Andreas Santoro Senior Consultant Plan-B GmbH Kolpingstr. 6 D-73433 Aalen Tel.: +49 (0) 177 1762129 Mail: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>-b-gmbh.com<mailto:[EMAIL PROTECTED]> Web: www.plan<http://www.plan-b-gmbh.com/>-b-gmbh.com<http://www.plan-b-gmbh.com/> Geschäftsführer Tobias Schmailzl Ralph Sturm Registergericht Ulm HRB 720355 Sitz der Gesellschaft ist Aalen Ust.ID DE250875731 ________________________________ Von: flexcoders@yahoogroups.com [EMAIL PROTECTED] im Auftrag von markflex2007 [EMAIL PROTECTED] Gesendet: Dienstag, 6. Mai 2008 16:23 An: flexcoders@yahoogroups.com Betreff: [flexcoders] Re: questionfor AdvancedDataGrid? Thanks. But I get error when I do this. private function QueueRequest():void{ dpFlat= new ArrayCollection([ {Region:"Southwest", Territory:"Arizona", Territory_Rep:"Barbara Jennings", Actual:38865, .... 'illegal assignment to class ArrayCollect' Now the question seems how to set a public arraycollection in function. Please help me.Thanks Mark --- In flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com>, Andreas Santoro <[EMAIL PROTECTED]> wrote: > > you have a local Variable in your function > > > private function QueueRequest():void{ > > var dpFlat:ArrayCollection = new ArrayCollection([ > {Region:"Southwest", Territory:"Arizona", > Territory_Rep:"Barbara Jennings", Actual:38865, > > CHANGE TO > > private function QueueRequest():void{ > > dpFlat= new ArrayCollection([ > {Region:"Southwest", Territory:"Arizona", > Territory_Rep:"Barbara Jennings", Actual:38865, > > > > Andreas Santoro > Senior Consultant > > > Plan-B GmbH > Kolpingstr. 6 > D-73433 Aalen > > Tel.: +49 (0) 177 1762129 > Mail: [EMAIL PROTECTED]<mailto:[EMAIL PROTECTED]>-b-gmbh.com<mailto:[EMAIL PROTECTED]> > Web: www.plan<http://www.plan-b-gmbh.com/>-b-gmbh.com<http://www.plan-b-gmbh.com/> > > Geschäftsführer > Tobias Schmailzl > Ralph Sturm > Registergericht Ulm > HRB 720355 > Sitz der Gesellschaft ist Aalen > Ust.ID DE250875731 > ________________________________ > Von: flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com> [EMAIL > PROTECTED]<mailto:flexcoders%40yahoogroups.com>] im Auftrag von markflex2007 [EMAIL PROTECTED] > Gesendet: Dienstag, 6. Mai 2008 15:55 > An: flexcoders@yahoogroups.com<mailto:flexcoders%40yahoogroups.com> > Betreff: [flexcoders] questionfor AdvancedDataGrid? > > > Hi, > > I have the following question about AdvancedDataGrid? > > The code works fine:(code 1) > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > backgroundColor="#32669D" > xmlns:ext="nl.wv.extenders.panel.*" > width="854"> > > <mx:Script> > <![CDATA[ > > import mx.collections.ArrayCollection; > > > [Bindable] > private var dpFlat:ArrayCollection = new ArrayCollection([ > {Region:"Southwest", Territory:"Arizona", > Territory_Rep:"Barbara Jennings", Actual:38865, > Estimate:40000}, > {Region:"Southwest", Territory:"Arizona", > Territory_Rep:"Dana Binn", Actual:29885, > Estimate:30000}, > {Region:"Southwest", Territory:"Central California", > Territory_Rep:"Joe Smith", Actual:29134, > Estimate:30000}, > {Region:"Southwest", Territory:"Nevada", > Territory_Rep:"Bethany Pittman", Actual:52888, > Estimate:45000}, > {Region:"Southwest", Territory:"Northern California", > Territory_Rep:"Lauren Ipsum", Actual:38805, > Estimate:40000}, > {Region:"Southwest", Territory:"Northern California", > Territory_Rep:"T.R. Smith", Actual:55498, > Estimate:40000}, > {Region:"Southwest", Territory:"Southern California", > Territory_Rep:"Alice Treu", Actual:44985, > Estimate:45000}, > {Region:"Southwest", Territory:"Southern California", > Territory_Rep:"Jane Grove", Actual:44913, > Estimate:45000} > ]); > > > ]]> > </mx:Script> > > <mx:Panel id="panel04" title="test panel" > x="255" y="100" width="575" height="342" > layout="absolute" > > <mx:Label x="15" > y="46" text=" Requests in the queue:" > width="152" f/> > > > > <mx:AdvancedDataGrid id="myADG" x="36" y="72" > initialize="gc.refresh();" width="520" height="218"> > <mx:dataProvider> > <mx:GroupingCollection id="gc" source="{dpFlat}"> > <mx:grouping> > <mx:Grouping> > > <mx:GroupingField name="Territory"/> > </mx:Grouping> > </mx:grouping> > </mx:GroupingCollection> > </mx:dataProvider> > > <mx:columns> > <mx:AdvancedDataGridColumn dataField="Region"/> > <mx:AdvancedDataGridColumn dataField="Territory"/> > <mx:AdvancedDataGridColumn dataField="Territory_Rep" > headerText="Territory Rep"/> > > </mx:columns> > </mx:AdvancedDataGrid> > > > </mx:Panel> > > </mx:Application> > > ---------------------------------------------------------- > > This code doesn't work (code 2) > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > backgroundColor="#32669D" > xmlns:ext="nl.wv.extenders.panel.*" > creati show="QueueRequest()" width="854"> > > <mx:Script> > <![CDATA[ > > import mx.collections.ArrayCollection; > > > [Bindable] > public var dpFlat:ArrayCollection ; > > > private function QueueRequest():void{ > > var dpFlat:ArrayCollection = new ArrayCollection([ > {Region:"Southwest", Territory:"Arizona", > Territory_Rep:"Barbara Jennings", Actual:38865, > Estimate:40000}, > {Region:"Southwest", Territory:"Arizona", > Territory_Rep:"Dana Binn", Actual:29885, > Estimate:30000}, > {Region:"Southwest", Territory:"Central California", > Territory_Rep:"Joe Smith", Actual:29134, > Estimate:30000}, > {Region:"Southwest", Territory:"Nevada", > Territory_Rep:"Bethany Pittman", Actual:52888, > Estimate:45000}, > {Region:"Southwest", Territory:"Northern California", > Territory_Rep:"Lauren Ipsum", Actual:38805, > Estimate:40000}, > {Region:"Southwest", Territory:"Northern California", > Territory_Rep:"T.R. Smith", Actual:55498, > Estimate:40000}, > {Region:"Southwest", Territory:"Southern California", > Territory_Rep:"Alice Treu", Actual:44985, > Estimate:45000}, > {Region:"Southwest", Territory:"Southern California", > Territory_Rep:"Jane Grove", Actual:44913, > Estimate:45000} > ]); > > } > > ]]> > </mx:Script> > > <mx:Panel id="panel04" title="test panel" > x="255" y="100" width="575" height="342" > layout="absolute" > > <mx:Label x="15" > y="46" text=" Requests in the queue:" > width="152" f/> > > > > <mx:AdvancedDataGrid id="myADG" x="36" y="72" > initialize="gc.refresh();" width="520" height="218"> > <mx:dataProvider> > <mx:GroupingCollection id="gc" source="{dpFlat}"> > <mx:grouping> > <mx:Grouping> > > <mx:GroupingField name="Territory"/> > </mx:Grouping> > </mx:grouping> > </mx:GroupingCollection> > </mx:dataProvider> > > <mx:columns> > <mx:AdvancedDataGridColumn dataField="Region"/> > <mx:AdvancedDataGridColumn dataField="Territory"/> > <mx:AdvancedDataGridColumn dataField="Territory_Rep" > headerText="Territory Rep"/> > > </mx:columns> > </mx:AdvancedDataGrid> > > > </mx:Panel> > > </mx:Application> > ---------------------------------------------------------- > > The different between code 1 and code 2 is : > > I assign ArrayCollection in a function in code 2, but I need to do the > code like code 2. > > Why code 2 show nothing in the AdvancedDataGrid? > > DO you know how to make code 2 work. Thanks for help. > > Mark >