+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / TreeView expand top node by default

TreeView expand top node by default

2 posts, 1 answered
  1. Jeremy
    Jeremy avatar
    17 posts
    Registered:
    28 Jul 2010
    01 Sep 2010
    Link to this post
    I'd like to have the top node of a treeview control expanded by default when the page loads. Any way of doing this?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Sep 2010
    Link to this post
    Hi Jeremy,

    You can use js to do this.  Below is a sample code

    function onLoad(sender, eventArgs) {
     
            var zeroNode = sender.get_allNodes()[0];
            if (zeroNode.get_nodes().get_count() > 0) {
                zeroNode.expand();
            }
    }


    <telerik:RadTreeview   OnClientLoad="onLoad" ID="RadTreeview1" runat="server" OnNodeDataBound="RadTreeview1_NodeBound"  OnDataBound="RadTreeview1_Bound" DataSourceID="SitemapDataSource1">
    </telerik:RadTreeview


    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
    Answered
2 posts, 1 answered