I am using a treeview for navigation purposes and I want a very specific behavior that I can not seem to find any examples of.
What I want is for the first level to show only on the top page. Then if you click a menu item that has child nodes, that node would expand only. This effect would be recursive or continuous down the tree. Only one node on each level could be expanded at any given time. Perhaps this is best described in examples:
Initial menu:
Top Level Menu Item 1
Top Level Menu Item 2
Top Level Menu Item 3
Top Level Menu Item 4
Then after you click Top Level Menu Item 2 you would see:
Top Level Menu Item 1
Top Level Menu Item 2
Level 2, Menu Item 2.1
Level 2, Menu Item 2.2
Level 2, Menu Item 2.3
Top Level Menu Item 3
Top Level Menu Item 4
At this point, if you clicked Top Level Menu Item 3, then it would collapse the children of Top Level Menu Item 2, and display the children nodes of Top Level Menu Item 3, thus you would see:
Top Level Menu Item 1
Top Level Menu Item 2
Top Level Menu Item 3
Level 2, Menu Item 3.1
Level 2, Menu Item 3.2
Level 2, Menu Item 3.3
Top Level Menu Item 4
Then, if you clicked one of the children, it would expand it:
Top Level Menu Item 1
Top Level Menu Item 2
Top Level Menu Item 3
Level 2, Menu Item 3.1
Level 2, Menu Item 3.2
Level 3, Menu Item 3.2.1
Level 3, Menu Item 3.2.2
Level 3, Menu Item 3.2.3
Level 2, Menu Item 3.3
Top Level Menu Item 4
So only one level 2 node, and only one level 3 node can be expanded at a time. Clicking a different level 2 node would collapse the currently expanded node and expand the clicked node. I don't want this to be client side. It will post back anyway, because each child node you click links to a page that will be loaded so there is no purpose to this behavior being implemented on the client side. Here is my current code, which is very basic:
Code:
<asp:TreeView runat="server" ID="trVwAssociations"
CssClass="subMenuArea"
DataSourceID="SiteMapDataSource1"
ShowExpandCollapse="false"
NodeIndent="15"
LeafNodeStyle-VerticalPadding="4"
ParentNodeStyle-VerticalPadding="4"
SelectedNodeStyle-VerticalPadding="4"
RootNodeStyle-VerticalPadding="4"
MaxDataBindDepth="3"
ExpandDepth="0"
PopulateNodesFromClient="false"
EnableClientScript="false"
EnableViewState="false" />
<asp:SiteMapDataSource runat="server" ID="SiteMapDataSource1"
StartFromCurrentNode="false"
ShowStartingNode="false"
StartingNodeUrl="/Associations/Default.aspx" />
Neil Timmerman
Programmer
Veris Consulting