GroupingCollection -> HierarchicalCollectionView

This post is a continuation of “Distinct Data Providers with GroupingCollection.” The code and example is extremely similar - there are a couple minor changes to accommodate one addition: the use of HierarchicalCollectionView.

What’s new?

We saw in the previous post that a GroupingCollection works very well for creating a grouped data provider for an AdvancedDataGrid or even for use in part in a List or ComboBox control. But there’s a(nother/ better) way to populate that distinct List or ComboBox from the GroupingCollection. Use a HierarchicalCollectionView. It’s a more elegant solution and also lets you use your grouped data to populate a Tree or Menu control! Continue reading to try it out and view code.

Try it out:

(Right click to view source)

ArrayCollection -> GroupingCollection -> HierarchicalCollectionView

We start with two dimensional data in the people ArrayCollection. The GroupingCollection source property binds to people which generates grouped (multi dimensional) data. The HierarchicalCollectionView source property binds to the GroupingCollection which provides a perfect data provider for the Tree, ComboBox and List controls. That’s a nice combination. An update to the people ArrayCollection updates all grouped and hierarchial data!

GroupingCollection and HierarchicalCollectionView are just two of several new collection classes in Flex 3 (see all mx.collections). These classes provide a ton of new functionality (which I am still absorbing).

Thanks for reading. If you found this helpful or have additional input please comment and let me know!

5 Responses to “GroupingCollection -> HierarchicalCollectionView”


  1. 1 Ben Throop

    Great stuff. I think I have an immediate use for this.

  2. 2 DracoDev

    Thank you so much for writing this up! I’ve been looking EVERYWHERE for info like this and this was presented extremely well. Very easy to follow and understand, THANKS!

  3. 3 Amy B

    Thanks for the great post :-). I was so inspired by it, I created a calendar example based on it http://flexdiary.blogspot.com/2008/09/groupingcollection-example-featuring.html

  4. 4 Erik

    Great example, but I suspect this only works with collections of basic Object types, because it doesn’t appear to work with my collection of value objects. Maybe I’m doing something wrong?

  1. 1 17 Pens » links for 2008-04-03

Leave a Reply