This is a migrated thread and some comments may be shown as answers.

How to expand RadTreeView node programatically?

6 Answers 1344 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rob
Top achievements
Rank 1
Rob asked on 22 Jul 2008, 09:33 PM
If I have a reference to a RadTreeViewItem, how do I programatically expand that item? I do not want to expand all levels beneath it. I just want to expand one level. My intent is to work my way down to a particular node and expand everything along the way.

Thanks
Rob

6 Answers, 1 is accepted

Sort by
0
Accepted
Valentin.Stoychev
Telerik team
answered on 23 Jul 2008, 06:23 AM
Hi Rob,

Just set the IsExpanded property to true of that RadTreeViewItem and you will have its child nodes displayed.

If you need to expand recursively - use the ExpandAll() method of the RadTreeViewItem (or on the RadTreeView if you want all the nodes expanded).

Greetings,
Valentin.Stoychev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
H.J
Top achievements
Rank 1
answered on 18 Aug 2011, 07:35 AM
thanks for the answer. but how about the Load on Demand mode. it doesn't work on loadondemand.
0
Petar Mladenov
Telerik team
answered on 23 Aug 2011, 01:45 PM
Hello H.J,

 Could you please elaborate more on your scenario and especially what you wish to achieve? This way we could be much better able to assist you and advice you. Since this a very old post, it will be also important to let us know the RadControl's version that you use. Thank you in advance.

All the best,
Petar Mladenov
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
H.J
Top achievements
Rank 1
answered on 05 Sep 2011, 05:02 AM
my telerik version is "Telerik 2010 Q1 SP1" and the dll version is 2010.1.415.35.
i use the Load On Demand mode of RadTreeView and i want to expand the root node programmetically after i added the root node on Page_Load for example. the obvious way is that the Expand Property of the node be true, but it's doesn't work.
so how can i expand the node programmetically on LoadOnDemand mode?
thanks for advance.
0
Kiril Stanoev
Telerik team
answered on 07 Sep 2011, 02:14 PM
Hello H.J,

You need to expand the root inside a dispatcher. Please consider the following approach.

<telerik:RadTreeView x:Name="treeView1" LoadOnDemand="treeView1_LoadOnDemand"
        IsLoadOnDemandEnabled="True" />

public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
 
        this.Loaded += new RoutedEventHandler(MainPage_Loaded);
    }
 
    void MainPage_Loaded(object sender, RoutedEventArgs e)
    {
        RadTreeViewItem root = new RadTreeViewItem();
        root.Header = "Root";
        this.treeView1.Items.Add(root);
 
        this.Dispatcher.BeginInvoke(() =>
        {
            root.IsExpanded = true;
        });
    }
 
    private void treeView1_LoadOnDemand(object sender, Telerik.Windows.RadRoutedEventArgs e)
    {
        RadTreeViewItem parent = e.OriginalSource as RadTreeViewItem;
 
        for (int i = 0; i < 5; i++)
        {
            RadTreeViewItem item = new RadTreeViewItem();
            item.Header = "Item " + i;
            parent.Items.Add(item);
        }
 
        parent.IsLoadingOnDemand = false;
    }
}

Give it a try and let me know if it helps.

Greetings,
Kiril Stanoev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
H.J
Top achievements
Rank 1
answered on 10 Sep 2011, 07:25 AM
im thankful for the time you spend, but right now im working on something else. i will reply as soon as i can.
Tags
General Discussions
Asked by
Rob
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
H.J
Top achievements
Rank 1
Petar Mladenov
Telerik team
Kiril Stanoev
Telerik team
Share this question
or