ADOBE FLEX 3
Adobe Flex 3 Data Visualization Developer Guide
298
</mx:AdvancedDataGrid>
</mx:Application>
The GroupingCollection instance reformats the data based on these fields so that internally it is represented by the
GroupingCollection instance, as the following example shows:
[{GroupLabel:"Southwest", children:[
{GroupLabel:"Arizona", children:[
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}]}
{GroupLabel:"Central California", children:[
{Region:"Southwest", Territory:"Central California",
Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}]}
{GroupLabel:"Nevada", children:[
{Region:"Southwest", Territory:"Nevada",
Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}]}
{GroupLabel:"Northern California", children:[
{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}]}
{GroupLabel:"Southern California", children:[
{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}]}
]}]
Notice that the representation consists of a data hierarchy based on the Region and Territory fields of the flat data.
The GroupingCollection instance still contains the original rows of the input flat data, but those rows are now
arranged in a hierarchy based on the grouping fields.
Calling the GroupingCollection.refresh() method
The GroupingCollection.refresh() method applies the settings of the GroupingCollection class to the data. You
must call this method any time you modify the GroupingCollection class, such as by setting the
grouping, source,
or
summaries properties of the GroupingCollection class. You also call the GroupingCollection.refresh()
method when you modify a GroupingField of the GroupingCollection class, such as by changing the
caseInsensitive, compareFunction, or groupingFunction properties.
Notice that in the previous example, the AdvancedDataGrid control calls the
GroupingCollection.refresh()
method in response to the
initialize event of the AdvancedDataGrid control.
Using the default MXML property of the GroupingCollection class
The grouping property is the default MXML property of the GroupingCollection class, so you can rewrite the
previous example as follows:
<?xml version="1.0"?>
<!-- dpcontrols/adg/SimpleGroupADGMXMLDefaultProp.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
include "SimpleFlatData.as"
]]>

Get ADOBE® FLEX® 3: ADVANCED DATA VISUALIZATION DEVELOPER GUIDE now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.