# ArrayColletion to AdvancedDataGrid

**URL:** <https://forum.kirupa.com/t/arraycolletion-to-advanceddatagrid/316321>\
**Category:** flash\
**Created:** [November 18, 2010, 1:10pm UTC](https://forum.kirupa.com/t/arraycolletion-to-advanceddatagrid/316321 "2010-11-18T13:10:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![guywalder](https://avatars.discourse-cdn.com/v4/letter/g/97f17d/32.png) [@guywalder](https://forum.kirupa.com/u/guywalder)\
**Post date:** [November 18, 2010, 1:10pm UTC](https://forum.kirupa.com/t/arraycolletion-to-advanceddatagrid/316321/1 "2010-11-18T13:10:42Z")

</div>

Hi flex forum,  
I’m new to flex but with some experience at java and c.  
I’m ahing a problem using an ArrayCollection as the DataProvider for my Advanced DataGrid.  
The ArrayCollection holds a number of Objects of type Guest that i created.  
When i try to display the results, the DataGrid can recognize the number of objects but the fields are all blank.  
I Found this example and tryed folowing it but no go.

> **[Populate datagrid from arraycollection of object](https://www.experts-exchange.com/questions/23464200/Populate-datagrid-from-arraycollection-of-object.html)**
>
> Hi, I'm new to flex so all help is appreciated. I'm creating a small app on AIR (for fun and some experience) which manages employees. I have a datagrid which I'm attempting to populate using an...

Any one has any suggestions for me?  
Thanks in advance,  
Guy.

Here is the code:

[//Guest.as](https://Guest.as)

[RemoteClass]  
public class Guest  
{  
//Class Veriables  
private var name:String;  
private var numOfPeople:int;  
private var side:String;  
private var innerSide:String;  
private var category:String;  
private var tableNum:int;  
private var apArrivel:Boolean;

```
	public function Guest(name:String, numOfPeople:int, side:String, iSide:String, category:String)
	{
		this.SetName(name);
		this.SetNumOfPeople(numOfPeople);
		this.SetSide(side);
		this.SetInnerSide(iSide);
		this.SetCategory(category);
		//this.SetTableNum(tableNum);
		//this.apArrivel = apAr;
	}........

```

// The mxml that contains the ArrayCollection and the DataGrid

\<mx:Script\>  
\<![CDATA[  
import Data.Guest;  
import mx.collections.ArrayCollection;  
import mx.controls.Alert;  
import mx.managers.PopUpManager;

```
      [Bindable]
      private var guestsA:ArrayCollection; 
      private var guest:Guest;
      private var popAddGuest:AddGuestForm;
      private static const ADD_TASK:String = "Click to Add Task";
     
      //Init the ArrayCollection with the given data 
      private function init():void
	  {
	   	 guestsA = new ArrayCollection();
	     guestsA.addItem(new Guest("baba",3,"bride","father","family"));
		 guestsA.addItem(new Guest("gala",3,"groom","father","family"));
		 guestsA.addItem(new Guest("shala",3,"groom","mother","friend"));
		 guestsA.addItem(new Guest("fala",3,"groom","father","family"));
		 //guestsA.addItem({title: ADD_TASK});			 
	  }
	  //Create popup window to add guest 
	  public function addGuest():void
	  {
	    popAddGuest = AddGuestForm(PopUpManager.createPopUp(this,AddGuestForm,true));
		PopUpManager.centerPopUp(popAddGuest);
		popAddGuest.submitButton.addEventListener(MouseEvent.CLICK, submitData);
		
	  }
	  //Gets all the details from the user and add the new guest to guestsA
	  private function submitData(event:Event):void
        { 
        	guest = new Guest(popAddGuest.fullName.text,popAddGuest.numOfGuests.value,popAddGuest.Side.selectedValue.toString(),
        	popAddGuest.InnerSide.selectedValue.toString(),popAddGuest.Category.selectedValue.toString());
      	 	this.guestsA.addItem(guest);
      	 	PopUpManager.removePopUp(popAddGuest);
      	  	Alert.show("Guest "+guest.GetName() +" was added");
        }
		

    ]]&gt;        
&lt;/mx:Script&gt;

&lt;mx:ArrayCollection id="blankArray1"&gt;
&lt;/mx:ArrayCollection&gt;

&lt;mx:TitleWindow width="500" height="500" horizontalAlign="center" verticalAlign="middle" title="Guests List"
	 fontSize="12" x="230" y="20"&gt;
	 
&lt;mx:AdvancedDataGrid id="adg" width="100%" height="100%"  
	dragEnabled="true" dragMoveEnabled="true" &gt;
	&lt;mx:dataProvider&gt;
		&lt;mx:GroupingCollection id="gc" source="{this.guestsA}"&gt;	
				&lt;mx:Grouping&gt;
					&lt;mx:GroupingField name="side"/&gt;
				&lt;/mx:Grouping&gt;
		&lt;/mx:GroupingCollection&gt;
	&lt;/mx:dataProvider&gt;
	
	&lt;mx:columns&gt;
		&lt;mx:AdvancedDataGridColumn dataField="name" headerText="Name" editable="false"/&gt;
		&lt;mx:AdvancedDataGridColumn dataField="numOfPeople" headerText="Number of People" editable="false"/&gt;
	&lt;/mx:columns&gt;		
&lt;/mx:AdvancedDataGrid&gt;

&lt;mx:AdvancedDataGrid id="blankdg" width="100%" height="100%" dataProvider="{blankArray1}" editable="true" dropEnabled="true"/&gt;
	
&lt;mx:Button id="addNew" label="Add Guest" click="addGuest()"/&gt;
&lt;/mx:TitleWindow&gt;	

```

\</mx:Application\>
