[CLOSED] select node and expand parent nodes

  1. #1

    [CLOSED] select node and expand parent nodes

    Hi,

    I have added a treepanel to my web application. I would like the ability to expand the tree from the selected node (i have the id of the node) upwards (bubble), leaving all other nodes on the tree collapsed. I would also like to highlight the selected node. I would like to achieve this from the codebehind. Is this doable?

    Thanks in advance

    Lee
    Last edited by Daniil; May 17, 2011 at 2:12 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Could you clarify why in code behind?

    Also please clarify your requirement using the following sample. What should happen?

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:TreePanel ID="TreePanel1" runat="server" AutoHeight="true">
            <Root>
                <ext:TreeNode Text="Root (level 0)">
                    <Nodes>
                        <ext:TreeNode Text="Node1 (level 1)">
                            <Nodes>
                                <ext:TreeNode Text="Node1 (level 2)">
                                    <Nodes>
                                        <ext:TreeNode Text="Node1 (level 3)" />
                                        <ext:TreeNode Text="Node2 (level 3)" />
                                    </Nodes>
                                </ext:TreeNode>
                            </Nodes>
                        </ext:TreeNode>
                        <ext:TreeNode Text="Node2 (level 1)">
                            <Nodes>
                                <ext:TreeNode Text="Node1 (level 2)">
                                    <Nodes>
                                        <ext:TreeNode Text="Node1 (level 3)" />
                                        <ext:TreeNode Text="Node2 (level 3)" />
                                    </Nodes>
                                </ext:TreeNode>
                            </Nodes>
                        </ext:TreeNode>
                    </Nodes>
                </ext:TreeNode>
            </Root>
            <Listeners>
                <Click Handler="node.expand();" />
            </Listeners>
        </ext:TreePanel>
        </form>
    </body>
    </html>
  3. #3
    Hi Daniil,

    I am using the treepanel to navigate to different sections of my application. When i click on a node, it will redirect to a specific page. I know which node has been clicked by the page i am on. The solution doesn't necessarily have to be server side but would need to occur on page load.

    Referring to your example, if i clicked:

    Root (level 0) -> Node1 (level 1) -> Node1 (level 2) -> Node1 (level 3)

    I would be redirected to a page (assuming the node selected had an href property).

    By retrieving the id of the node i would want Node2 (level 1) and its children collapsed. I would also want the clicked node (Node1 (level 3)) selected/highlighted

    Lee
  4. #4
    The solution doesn't necessarily have to be server side but would need to occur on page load.
    I would suggest you to use AfterRender event of TreePanel with some delay to ensure the nodes are rendered.

    And the methods you can interested in:
    TreePapel1.getNodeById(nodeId);
    node.expand();
    node.collapse();
    TreePanel1.getSelectionModel().select(node); //to highlight

Similar Threads

  1. Replies: 16
    Last Post: Jul 19, 2011, 3:53 AM
  2. Treepanel: expand ~1500 nodes gives error
    By RobOtter in forum 1.x Help
    Replies: 3
    Last Post: Jul 14, 2011, 12:33 PM
  3. Replies: 1
    Last Post: Nov 24, 2010, 3:04 PM
  4. Replies: 1
    Last Post: Nov 17, 2010, 12:42 PM
  5. How to expand all child nodes for current node?
    By dbassett74 in forum 1.x Help
    Replies: 2
    Last Post: May 26, 2009, 2:53 PM

Posting Permissions