0 Replies Latest reply on Apr 18, 2008 2:20 PM by rmeador

    creating custom hierarchical data provider

    rmeador
      Hi,
      I'm trying to create a custom dataprovider for a 3rd party chart control. As far as I can tell, it works just like any Flex-provided hierarchical dataprovider control. My problem doesn't have to do with the control directly, as I haven't yet even tried to interface my dataprovider with their control (that's why I'm posting here). I'm having a lot of troubling figuring out how to implement IHierarchicalData and IHierarchicalCollectionView (or figuring out what to extend and override to give me the functionality). The documentation doesn't seem to be detailed enough to help me .

      I can't use a normal XML dataprovider because the XML I have contains child elements that are data, so I can't just use the hierarchy of the XML itself. I need to process the XML in some way using code that actually understands its structure. I intend to process this into a class that implements IHierarchicalData. The documentation is really vague on what the results of a call to getChildren() returns (and how the calling code then breaks the children apart so it can call getData() on each), but I was able to figure that out by looking at the source for the chart control I'm using (it appears to expect an ArrayCollection... why isn't the IHierarchicalData interface typed as such?). My biggest problem is understanding the IHierarchicalCollectionView. It has methods to add and remove child nodes, but I don't see how it's possible for it to do that. It only has a reference to an IHierarchicalData, which provides no methods to perform those operations. When I wrap my IHierarchicalData in the default HierarchicalCollectionView object (which is just what the chart does, as far as I can tell) and use methods like addChild(), I get a null reference error, as mentioned in this stack trace snippet:

      Error #1009: Cannot access a property or method of a null object reference.
      at mx.collections::HierarchicalCollectionView/addChild()

      I believe I need the HierarchicalCollectionView (or to extend a class that implements the IHierarchicalCollectionView interface or implement it myself) because I need to use its functions to modify my tree structure so that when I change the data, the chart will update. Is this a correct assumption? If so, how do I use those functions on the HierarhicalCollectionView? What is it doing internally? I don't understand how it can be manipulating the tree in a type-safe manner having only an IHierarchicalData reference to work with, and if it's doing it in a non-typesafe manner, I need to know what methods it's calling on my tree or node objects, which don't appear to be documented in the docs for IHierarchicalCollectionView.

      If I'm totally off-base in the best way to accomplish my goal, please let me know. I'd also appreciate any information you could give me, such as info on the hierarchy interfaces that goes beyond the docs. Some source code for HierarchicalCollectionView would be super helpful (only for reverse engineering; it should really be documented somewhere), but I haven't been able to find any. Isn't it open source?

      Thank you very much for any help you can provide.