Share on Google+Share on Google+

Spark DataGroup Container in Flex4

DataGroup container is Spark container in Flex 4 hold components that implements IVisualElement interface and subclasses of DisplayObject.

Spark DataGroup Container in Flex 4:

DataGroup container is a Spark container in Flex 4 hold components that implements IVisualElement interface and subclasses of DisplayObject. User uses these containers when take data item as children. These container uses item renderer that provide visual representation of the data item in the container. Item renderer converts data item in the format type which is required by the container. These components also use data provider to provide data for these components. The data provider is the by default property for this component. The tag is <s:DataGroup />. In this example you can see mix data items like String and Objects.


 <?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx=""





private function add():void {

var newChild:String = "new child";


addDG.visible = false;

removeDG.visible = true;


private function remove():void {


addDG.visible = true;

removeDG.visible = false;




<s:Panel title="Data Group Container Example." width="201" height="262" borderColor="0x3081D2">


<s:DataGroup id="dg1" itemRenderer="spark.skins.spark.DefaultItemRenderer">











<s:DataGroup id="dg2" itemRenderer="spark.skins.spark.DefaultComplexItemRenderer">





<s:Button id="addDG" label="Add new child" click="add()"/>

<s:Button id="removeDG" label="Remove new child" click="remove()" visible="false"/>






Add and Remove item in data provider for the DataGroup container in run time. There are two type of item renderer used in this example spark.skins.spark.DefaultItemRenderer and spark.skins.spark.DefaultComplexItemRenderer. spark.skins.spark.DefaultItemRenderer item renderer use to a simple data item like String or Number objects. spark.skins.spark.DefaultComplexItemRenderer use to more complex data item like Objects.


Running Application:

To view this page ensure that Adobe Flash Player version 10.0.0 or greater is installed.

Download this code


Posted on: April 24, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.


Advertisement null