[RESOLVED]Navigation Treeview: how to open nested (not collapsed)

Hi,

I would like to change the treeview to open "nested" instead of all collapsed by default.

I’m using a sitemap as the datasource for my treeview.

When I preview the page the entire treeview is collapsed (and it is very long). I would prefer to see the parent nodes only by default and only when clicking on the parent, the child nodes collapse respectively.

How can I do that?

The code is:

<div
id="left_col">
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" Height="755px" ImageSet="Arrows" Width="16px">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</div>

Hi Nebulosa,

Based on your description, my understanding is that you would like to set the child treeview node to collapsed as default.

If so, you can try to use the ExpandDepth property of TreeView control, when you set the value as "0", the treeview will only display the parent node.

More information about the ExpandDepth please refer to:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.expanddepth(v=vs.110).aspx

Hope it helps.

Best Regards,
Terry Guo

Leave a Reply