Home - Forums-.NET - FlyTreeView (ASP.NET) - Collapse All Sibling Nodes

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Collapse All Sibling Nodes
Link Posted: 31-Jan-2008 16:20
Hi I am trying to collapse all sibling nodes with the example found here (see url below), but somehow I am not able to get it work using client-side javascript. Can someone help me out here please? All I want is  when you select any node of treeview all sibling nodes should collapse.  

http://www.9rays.net/asp.net/treeview/Demos.aspx?demo=program_client_sample1

The code given on the page is as below, but then how show I use it. I tried different Methods, but keep getting errors. Any help in the below matter would be highly appreciated.

Thanks a bunch.




Link Posted: 31-Jan-2008 22:07
The URL that you provided is from ASP.NET 1.1 demo site.
Are you talking about ASP.NET 2.0 (or higher) version of the control?

The client-side model of both completely differ.
I can easily create a similar script for ASP.NET 2.0 version, if you actually need it.
Link Posted: 01-Feb-2008 04:38
Hi - That would be great! Yes I need it for ASP.NET 2.0 version, to work with Client Side Javascript. So basically when I click a node in one of the parent node, all other parent nodes and its sibling must collapse, so that only the selected nodes parent node is open.

Would appreciate your quick reply, becoz my company is planning to buy this product as soon as I can show them the demo. Also I would appreciate if you could tell me what eventhandler needs to be used from Client side, which solves my problem above. A code snippet would be great.

Thanks you.
Link Posted: 01-Feb-2008 05:10
Here is a complete page code (just copy to a blank page): [code] <%@ Register Assembly="NineRays.WebControls.FlyTreeView" Namespace="NineRays.WebControls" TagPrefix="NineRays" %>
[/code] The code implements same functionality as the asp.net 1.1 version demo page.
Link Posted: 01-Feb-2008 05:27
Hi Thanks for the quick reply. I will try it and let you know. Btw I had a quick question, how can I make sure all the nodes are in collapse state when the tree initially loads? I tried using Expand Level with Vista Image set, but all the nodes always remain open on initial page load. Also one last thing , I want to make sure that after PostBack occurs, I want that the node which I had selected before postback, only its parent node remains open and all other sibling will close? is that possible with the code you sent me? Thanks again! [quote="EvgenyT"]Here is a complete page code (just copy to a blank page): [code] <%@ Register Assembly="NineRays.WebControls.FlyTreeView" Namespace="NineRays.WebControls" TagPrefix="NineRays" %>
[/code] The code implements same functionality as the asp.net 1.1 version demo page.
Link Posted: 01-Feb-2008 05:50
Btw I had a quick question, how can I make sure all the nodes are in collapse state when the tree initially loads?

Nodes are collapsed by default. If node.Expanded is true or ExpandLevel of a parent node is positive - then the node is expanded. Otherwise it is collapsed.

If you need to reset all nodes state after postback, then you need to get all nodes FlyTreeView.FindAll() and set every node's Expanded to null (or even to false to override ExpandLevel setting).

Also one last thing , I want to make sure that after PostBack occurs, I want that the node which I had selected before postback, only its parent node remains open and all other sibling will close? is that possible with the code you sent me?

As you can see from my code, the collapseSiblingNodes function does not collapse parent nodes, only sibling nodes of parent nodes.
Link Posted: 04-Feb-2008 07:39
Thanks! I just recompiled and all worked fine.