The DataGroup and SkinnableDataContainer containers require
an item renderer to draw each container child on the screen. By
default, the DataGroup and SkinnableDataContainer containers do
not define an item renderer. You can configure the containers to
use the item renderers provided by Flex, or define your own custom
item renderer.
Flex ships with two item renderers: spark.skins.spark.
spark.skins.spark.DefaultItemRenderer Converts its data item
to a single String for display in a Spark Label control. It is useful
when displaying a scalar data item, such as a String or a Number,
that can be easily converted to a String.
spark.skins.spark.DefaultComplexItemRenderer Displays a Flex
component in a Group container. Each component is wrapped in its
own Group container. Therefore, it is useful when the children of
the container are visual elements, such as Flex components.
The following example uses the DefaultItemRenderer with a DataGroup container:
Each data item of the container is a String. Because you use
the DefaultItemRenderer with the container, each String appears
in the container in a Label control.
If the data item is of type Object or is a data type that is
not easily converted to a String, then you either have to convert
it to a String, or define a custom item renderer to display it.
For more information, see Passing data to a Spark item renderer.
The following example shows a DataGroup container where all its
children are Flex components. The DataGroup class uses the DefaultComplexItemRenderer
to display each child:
Because you use the DefaultComplexItemRenderer with the container,
each Button control appears in the container nested in its own Group
container. By wrapping each control in a Group container, the item
renderer can support selection highlighting for the individual children.
However, if you do not want each control to appear in its own Group
container, set the item renderer to null, as shown
below:
<s:DataGroup itemRenderer="{null}">
Note: If you are only displaying visual elements in a DataGroup
or SkinnableDataContainer container, you should instead use the
Group or SkinnableContainer containers.
You might be able to create your application by using just the
DefaultItemRenderer and DefaultComplexItemRenderer classes. However,
you typically define a custom item renderer if your data items are
not simple values, or if you want more control over the appearance
of your container children. For more information on creating a custom
item renderer, see Define a custom Spark item renderer.