Tree and Lazy or Paged Data

The Flex Tree control (mx.controls.Tree) is the subject of many complaints. It’s pretty finicky if you don’t use a dataProvider where the data is “all there”. Any attempts to lazily load in nodes must be coded carefully. If you don’t tweak the DataDescriptor properly it won’t work.
Tree does have one major flaw, and that is that it can’t handle a dataProvider that throws ItemPendingErrors as data sets that come from LiveCycle DataServices do. Tree uses an undocumented pair of classes to effectively linearize the current set of open nodes into a dataProvider that its base class (List) can handle. The code for that was scrambled together at the last minute and wasn’t deemed sufficient enough for the AdvancedDataGrid, so our AdvancedDataGrid team developed their own HierarchicalCollectionView classes and beefed them up to handle ItemPendingErrors. Due to various scheduling and logistical issues, Tree was left by the side of the road, stuck with its undocumented HierarchicalCollection classes that can’t handle ItemPendingErrors.
At the tail end of Flex 3, several customers were in need of a Tree that could handle ItemPendingErrors. THe shortest route to such a thing was to create a subclass of Tree that could handle the AdvancedDataGrid’s HierarchicalCollectionView. Example and source code are below. You’ll see the acronym “DMV” throughout because the AdvancedDataGrid and HierarchicalCollectionView are part of the Data Management and Visualization package (which requires the Professional versions and/or more money) so those of you trying to go the cheap route won’t be able to leverage this code. Also, you won’t need this unless your data source throws ItemPendingErrors when an attempt is made to fetch data that hasn’t been paged in yet, and unless you developed your own, you are using one of our data services which also cost you some money.
The example comes with a test tool we wrote that throws lots of ItemPendingErrors so we can try to find all the code paths that are sensitive to it. Unlike most of the posts on my blog, this one actually got some QA time, but the usual caveats apply.
Run Example
Download Source