treeview as nagivation question.

Last post 12-01-2006 12:47 AM by pushp_aspnet. 2 replies.

Sort Posts:

  • treeview as nagivation question.

    11-30-2006, 11:37 PM
    • Member
      120 point Member
    • JoeyCrack
    • Member since 09-02-2006, 2:02 PM
    • Posts 23

    hi, i have a treeview i'm wanting to use as a left side nagivation menu.

     it has a root node, 2 parent nodes (each parent node has 30 leaf nodes).

    q1. how do i set it so by default when the page loads the treeview isn't expanded/collapsed?

    q2. when the top parent node is minimised and the 2nd parent node is expanded, whenever a user clicks on a leaf node from the 2nd parent node it automatically maximises the top parent node aswell, how do i set it so it doesn't do this?

    thanks in advance!
     

  • Re: treeview as nagivation question.

    12-01-2006, 12:43 AM
    Answer
    • Contributor
      2,209 point Contributor
    • pushp_aspnet
    • Member since 10-19-2006, 9:27 AM
    • Hyderabad,India
    • Posts 447

    Hi joeycrack,

    >>q1. how do i set it so by default when the page loads the treeview isn't expanded/collapsed?

    Set ExpandDepth for tree as 0, treeview.ExpandDepth = 0; in the page_load

    >> q2. when the top parent node is minimised and the 2nd parent node is expanded, whenever a user clicks on a leaf node from the 2nd parent node it automatically maximises the top parent node aswell, how do i set it so it doesn't do this?

    In the SelectedNodeChanged handler for leaf node (in code behind ) put this code:

     protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
        {
            TreeView1.ExpandDepth = 0;

        if(TreeView1.SelectedNode.Parent != null)
            TreeView1.SelectedNode.Parent.Expand();
        }

     

    Hope this helps.

    cheers!! 

     

    Home Is Where the Wind Blows
    http://pushpontech.blogspot.com
  • Re: treeview as nagivation question.

    12-01-2006, 12:47 AM
    • Contributor
      2,209 point Contributor
    • pushp_aspnet
    • Member since 10-19-2006, 9:27 AM
    • Hyderabad,India
    • Posts 447

    I guess its better to use CollapseAll() instead of setting ExpandDepth:

     protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
        {
            //TreeView1.ExpandDepth = 0;

            TreeView1.CollapseAll();

        if(TreeView1.SelectedNode.Parent != null)
            TreeView1.SelectedNode.Parent.Expand();
        }

     

     

    Home Is Where the Wind Blows
    http://pushpontech.blogspot.com
Page 1 of 1 (3 items)