This is a migrated thread and some comments may be shown as answers.

Trying to Collapse the Level==0 Nodes

2 Answers 52 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 06 Apr 2010, 03:57 PM
Hello, i think i've tried just about every option i can find to Collapse the ChildNodes of the Level==0 parent i suspect that 
is has something to do with the fact that i'm not actually using the " e " in e.Nodes.... to try and do the actual process
but i'm trying to use the actual RadTreeView ID collection itself, but the reason i'm doing that is because i want to Collapse 
all of the Level 0 AAAA node when i then select the Level 0 BBBB node for instance, so if i tried to use the " e " value
i would be pointing to the BBBB node which i what i want to expand, but before i expand it, i want to Collapse the AAAA node 
just for example. thanks for any ideas or suggestins! 

   protected void trvDB2_NodeExpand(object sender, RadTreeNodeEventArgs e)  
    {  
        foreach (RadTreeNode rtn in trvDB2.Nodes)  
        {  
            if (rtn.Level == 0 && !e.Node.Text.Equals(rtn.Text))  
            {   
                int    rntnc = rtn.Nodes.Count;  
                //Nodes   ns = rtn.Nodes.Remove();  
                //for (int index = rtn.Nodes.Count - 1; index >= 0; index--)  
                for   (int index = rtn.Nodes.Count - 1; index >= 0; index--)  
                {  
                    //string rtnrtntxt0 = rtn.Nodes[index].Text;  
                    //if (rtn.Nodes[index].Level==1)  
                    //{  
                    //    //string rtnrtntxt = rtn.Text;  
                    //    //string rntnit = rtn.Nodes[index].Text;  
                    //    rtn.Nodes.Clear();  
                    //    //rtn.Nodes[index]  
                    //    //rtn.Nodes[index];  
                    //    //rtn.Nodes  
                    //}  
                }  
                //string x = rtn.Text;  
                //IEnumerator ie =  rtn.Nodes.GetEnumerator();  
                //while (ie.MoveNext())  
                //{  
                //    ((RadTreeNode)(ie.Current)).Nodes.Clear();  
                //}  
                //foreach (RadTreeNode rtn2 in rtn.Nodes)  
                //{  
                //     //string r = rtn 
                //     //rtn2.Nodes.Clear();  
                //     //rtn2.c  
                //     //rtn2.Nodes.Clear();  
                //     //rtn.Nodes.Remove(rtn2);  
                //}  
                //rtn.Nodes.Remove();  
                //rtn.CollapseChildNodes();  
                //rtn.CollapseParentNodes();  
            }  
        }  
        for (int index = trvDB2.CheckedNodes.Count - 1; index >= 0; index--)  
        {  
            //trvDB2.CheckedNodes[index].Checked = false;  
        }  
        for (int index = trvDB2.Nodes.Count - 1; index >= 0; index--)  
        {  
            string trvnodetxt = trvDB2.Nodes[index].Text;  
            if (trvDB2.Nodes[index].Level == 0 && !e.Node.Text.Equals(trvnodetxt))  
               {  
                   trvDB2.Nodes[index].CollapseChildNodes();  
                   trvDB2.Nodes[index].Nodes.Clear();  
                   trvDB2.Nodes[index].Remove();  
               }  
        }  
        //e.Node.CollapseChildNodes();  
        //e.Node.CollapseParentNodes();  
        //PopulateNodeOnDemand(e, TreeNodeExpandMode.ServerSideCallBack);  
    } 

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 08 Apr 2010, 12:35 PM
Hello,

If you're using ExpandMode="ServerSideCallBack" for the nodes, you cannot modify the other nodes in NodeExpand event handler  - the reason for this is that you make a callback to the server and only new nodes can be added to the expanded node. You should either use ExpandMode="ServerSide" or collapse the other nodes on the client.

All the best,
Yana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Bob
Top achievements
Rank 1
answered on 11 Apr 2010, 03:48 AM
great that was the solution Yana, thanks alot!
Tags
TreeView
Asked by
Bob
Top achievements
Rank 1
Answers by
Yana
Telerik team
Bob
Top achievements
Rank 1
Share this question
or