Advanced DataGrid

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”;
layout=”vertical” creationComplete=”init()”>
import mx.collections.IHierarchicalCollectionView;

private function init():void
adg.dataProvider = gc;
IHierarchicalCollectionView(adg.dataProvider).openNodes = gc.getRoot();

// counter to maintain the uid
private var count:int = 0;

private function grpObjFunc(value:String):Object
// we need to assign the same uid for same grouped Objects
// use count or value + count
return {uid:value + count++};

<!– Source Collection –>
<mx:ArrayCollection id=”arr”>
<mx:Object name=”A” qty=”5″ cost=”100″ />
<mx:Object name=”A” qty=”10″ cost=”200″ />
<mx:Object name=”B” qty=”4″ cost=”200″ />
<mx:Object name=”C” qty=”3″ cost=”300″ />
<mx:Object name=”C” qty=”5″ cost=”350″ />
<mx:Object name=”D” qty=”2″ cost=”400″ />
<mx:Object name=”E” qty=”1″ cost=”500″ />

<!– Grouping Collection taking source as the ArrayCollection defined above–>
<mx:GroupingCollection id=”gc” source=”{arr}”>
<mx:Grouping groupingObjectFunction=”grpObjFunc” >
<mx:GroupingField id=”gf” name=”name” />

<!– Array of Summaries, to be assigned when summaries are needed –>
<mx:Array id=”summ”>
<mx:SummaryField dataField=”cost” operation=”SUM” />

<mx:AdvancedDataGrid id=”adg”   dataProvider=”{gc}” height=”300″>
<mx:AdvancedDataGridColumn  dataField=”name” />
<mx:AdvancedDataGridColumn dataField=”qty” />
<mx:AdvancedDataGridColumn dataField=”cost” />

~ by mjcprasad2000 on February 16, 2009.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: