Simple treePanel I am currently populating with hard coded values till I get it working properly.

Sets up exactly the way I want


After I expand the first node, that node will not collapse unless I click the collapse all button. After the node is collapsed, it will no longer expand. Using the expand all and collapse all buttons always work, but the specific node will not expand or collapse. Testing proves that the expandNode and collapseNode events are not firing after the first time.


The Click event does work every time. I need to identify if the node that was clicked is a leaf or not. Processing will be different based on this information. I explicitly set the leaf property on the node when I create it, but when passing it via ExtraParms, it is always true regardless of value set in node.




Mark Up:
<ext:TreePanel runat="server" ID="tpPicker" AutoHeight="true" AutoScroll="true" AutoWidth="true" Icon="Application" Title="Select a child...">
                        <TopBar>
                            <ext:Toolbar runat="server" ID="tbPicker">
                                <Items>
                                    <ext:Button runat="server" Text="Expand All">
                                        <Listeners>
                                            <Click Handler="#{tpEnrolls}.expandAll();" />
                                        </Listeners>
                                    </ext:Button>
                                    <ext:Button runat="server" Text="Collapse All">
                                        <Listeners>
                                            <Click Handler="#{tpEnrolls}.collapseAll();" />
                                        </Listeners>
                                    </ext:Button>
                                </Items>
                            </ext:Toolbar>
                        </TopBar>
                        <BottomBar>
                            <ext:StatusBar runat="server" ID="tpStatusBar" AutoClear="1000" />
                        </BottomBar>
                        <Listeners>
                            <Click Handler="#{tpStatusBar}.setStatus({text: 'Node Selected: ' + node.text + '', clear: true});" />
                            <CollapseNode Handler= "#{tpStatusBar}.setStatus({text: 'Node Collapsed: ' + node.text + '', clear: true});" />
                            <ExpandNode Handler="#{tpStatusBar}.setStatus({text: 'Node Expanded: ' + node.text + '', clear: true});" />
                        </Listeners>
                        <DirectEvents>
                            <Click OnEvent="tpNodeClick">
                                <ExtraParams>
                                    <ext:Parameter Name="NodeID" Mode="Raw" Value="node.id" />
                                    <ext:Parameter Name="Leaf" Mode="Raw" Value="node.leaf" />
                                </ExtraParams>
                            </Click>
                        </DirectEvents>
                    </ext:TreePanel>

Code Behind:


Load Tree:




            List<Parent> parents = this.GetData();


            parents.ForEach(delegate(Parent parent)
            {
                Ext.Net.TreeNode parentNode = new Ext.Net.TreeNode(parent.Name, Icon.Calendar);
                parentNode.NodeID = parent.ID.ToString();
                parentNode.Leaf = false;
                root.Nodes.Add(parentNode);    


                parent.Children.ForEach(delegate(Child child)
                {
                    Ext.Net.TreeNode childNode = new Ext.Net.TreeNode(child.Name, Icon.Clipboard);
                    childNode.NodeID = child.ID.ToString();
                    childNode.Leaf = true;
                    parentNode.Nodes.Add(childNode);
                });
            });



	private List<Parents> GetData()
        {
            List<Parent> ParentList = new List<Parent>();
            List<Child> ChildList = new List<Child>();


            Child kid1 = new Child("Lisa", 55);
            Child kid2 = new Child("Bart", 56);
            ChildList.Add(kid1);
            ChildList.Add(kid2);


            Parent parent1 = new Parent("Marge", 55);
            parent1.Children = ChildList;


            ParentList.Add(parent1);


            return ParentList;
        }



Click Event:


[DirectMethod]
        protected void tpNodeClick(object sender, DirectEventArgs e)
        {
            string personID = string.Empty;
            string treeNodeID = e.ExtraParams["NodeID"].ToString();
            string leaf = e.ExtraParams["Leaf"].ToString();


            //Do stuff based on parent or child node clicked.            
        }