Tree Node App Example

Sorry Jake your going to hate me soon for so many posts!

To be fair our demo / proof is almost done and we have the chart working and looking pretty slick so we are close to being good to go

Just a few issues though which i am hoping you could help clear up.

I have been using the treenodeapp as my reference and used 2 classes from this to help with the expanding and collapsing nodes, they are TreeAppNode and TreeDraggingTool.

My issue is, even though the graph is collapsable and expandable, there is no way to get the name of the parent. For example if i click on the node and capture the event, and then do node.parent i cant seem to figure out why i cant get the name. Here is my example code;

    protected void goView1_ObjectSingleClicked(Object sender, GoObjectEventArgs evt)
    {
        GoObject obj = evt.GoObject;
        TreeAppNode n = obj.TopLevelObject as TreeAppNode;
        if (n != null)
        {
            //the line below needs to be, if n.text is equal to n's parent  nodes text
            if (n.Text.Equals("Click to view compound image"))
            {
                ClickedDataHandler c = new ClickedDataHandler("some data");
                c.getImage();
            }
        }
    }

I appreciate there is a n.parent and an n.parentnode but neither do as i would have thought they should.

My second question is, the graph draws from left to right as in the GOUserGuid example on page 160. Is there anyway to make it top to bottom instead?

Thanks for your time.

What is the type of evt.GoObject? is “n” null after the cast?



The children in TreeApp are just being created to the right of the parent. You could use the Tree Layout. See the Layout user guide, or the LayoutDemo Sample.

Northwoods.Go.GoPort is the type of evt.GoObject and n is not null, the code i posted gets the data from inside the tags. The xml structure looks liek this

<node label="Chemical structure" >
  <node label="Click to view compound image" />
</node>

OH! You don’t want the label of the node you clicked on, you want the label of the top of the tree? ParentNode, etc just go up the “tree” of objects with the GoDocument, they don’t traverse links.



There is a section in the User Guide on traversing graphs, and SubGraphApp has a “highlight the xyz” UI that shows you and example of this.