Grouping is a interesting concept in Flex. While most people use the GroupingCollection (and its successor GroupingCollection2) in combination with the hierarchical data support of the AdvancedDataGrid (and by extension ExtendedAdvancedDataGrid), for the longest time, we did not support it in Ultimate. This was done primarily because Ultimate provided a rich mechanism for providing information about Grouping UI within its own configuration. The ADG never had this, and therefore had to resort to weird things for summary placement, sorting within grouping etc.. For Ultimate, you provided this information within the grids own declaration, making it more natural, and led to less pull your hair out moments.

Anyway, a few customers are used to using the GroupingCollection, so in the upcoming 3.0 release, we will be adding built in support for this. However, you don’t necessarily have to wait for 3.0 to leverage this feature. The fact remains that Ultimate basically takes a flat array, with each item exposing a “children” property that will contain the children of the node. GroupingCollection essentially does the same thing, but exposes it via a cursor. So all we are talking about is taking the flat collection and leveraging GroupingCollection it to convert it into a Hierarchical structure. Code example follows:

MultipleGrouping.mxml (5.81 kb)

Now, this above example works great for grouped data (Where there is just one set of per grid). But Ultimate supports MUCH more than that. And the GroupingCollection will end up giving you just the grouping name. But you want a set of columns at each hierarchical level. The below support ticket explains this very well:


“Suppose I have a flat data structure with fields A,B,C,D,E,F,G,H,J I first want to group the fields by field A, which would be the root shown in the example (the columnlevel with initialsortfield='legalname') with columns showing fields H and J.

Then when I expand that, I want to group by field B, with fields F and G as columns (this would correspond to columnlevel with initialsortfield='dealdate' in the example).

Then when expanding that, I would like to group by field C with field D as the column.”

So now, you can no longer use the GroupingCollection, because not only do you want o group, but also you want to extract attributes at each grouping level. So we came up with a little routine that does this for you. Example Code follows.

MultipleGrouping_Manual.mxml (5.66 kb)