Open Node

7 posts, 0 answers
  1. Andy
    Andy avatar
    16 posts
    Member since:
    Jun 2014

    Posted 04 Jul 2014 Link to this post

    Hi,

    Unless I’m missing something obvious I can’t seem to find
    a way to expand a treeview to a particular node?


    Please advise?

    TIA
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2014 in reply to Andy Link to this post

    Hi Andy,

    Try to use the client side expand method to expand a particular node. Please have a look into the sample code snippet which expands a node from JavaScript.

    ASPX:
    <telerik:RadTreeView ID="rtreeviewTestDemo" runat="server">
        <Nodes>
            <telerik:RadTreeNode Text="Node1">
                <Nodes>
                    <telerik:RadTreeNode Text="Node1.1">
                    </telerik:RadTreeNode>
                    <telerik:RadTreeNode Text="Node1.2">
                    </telerik:RadTreeNode>
                </Nodes>
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>

    JavaScript:
    function pageLoad() {
        var node = $find("<%=rtreeviewTestDemo.ClientID%>");
        node.findNodeByText("Node1").expand();
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy
    Andy avatar
    16 posts
    Member since:
    Jun 2014

    Posted 04 Jul 2014 in reply to Shinu Link to this post

    Thanks for the suggestions. Unfortunately I need to be able to do this server side, do
    you have a C# example please?

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 04 Jul 2014 in reply to Andy Link to this post

    Hi Andy,

    Please try the below C# code snippet.

    C#:
    RadTreeNode node = rtreeviewTestDemo.Nodes.FindNodeByText("Node1") as RadTreeNode;
    node.Expanded = true;

    Thanks,
    Shinu.
  6. Andy
    Andy avatar
    16 posts
    Member since:
    Jun 2014

    Posted 04 Jul 2014 in reply to Shinu Link to this post

    Hi,

    Thanks for the suggestion, unfortunately it does not expand the treeview?
  7. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 06 Jul 2014 in reply to Andy Link to this post

    Hi Andy,

    Unfortunately I couldn't replicate the issue at my end. In order to expand a node try to set the Expanded property and ExpandChildNodes & ExpandParentNodes methods are there to expand the child node and parent node of a RadTreeNode. Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadTreeView ID="rtreeviewTestDemo" runat="server">
        <Nodes>
            <telerik:RadTreeNode Text="Node1">
                <Nodes>
                    <telerik:RadTreeNode Text="Node1.1">
                        <Nodes>
                            <telerik:RadTreeNode Text="Node1.11">
                            </telerik:RadTreeNode>
                            <telerik:RadTreeNode Text="Node1.12">
                            </telerik:RadTreeNode>
                        </Nodes>
                    </telerik:RadTreeNode>
                    <telerik:RadTreeNode Text="Node1.2">
                    </telerik:RadTreeNode>
                </Nodes>
            </telerik:RadTreeNode>
        </Nodes>
    </telerik:RadTreeView>

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadTreeNode parentNode = rtreeviewTestDemo.Nodes.FindNodeByText("Node1") as RadTreeNode;
        RadTreeNode childNode = parentNode.Nodes.FindNodeByText("Node1.1") as RadTreeNode;
        parentNode.ExpandChildNodes();
        childNode.ExpandParentNodes();
    }

    Please provide your code if it doesn't help.
    Thanks,
    Shinu.
  8. Doug
    Doug avatar
    70 posts
    Member since:
    Aug 2014

    Posted 01 Aug 2014 in reply to Shinu Link to this post

    I expand each with a loop that travels up the tree

    Dim node As RadTreeNode = RadTreeView1.FindNodeByAttribute("CategoryId", Request.QueryString("CategoryID"))
    If Not IsNothing(node) Then
       node.Selected = True
       node.Expanded = True
       ...
    End If
    While (Not IsNothing(node))
        node.ExpandParentNodes()
        ...
    node.ExpandMode = TreeNodeExpandMode.ClientSide
    node = node.ParentNode
    End While
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017