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

Can not expandable nodes on non-Load nodes RadTreeView WPF(load-on demandable tree)

1 Answer 75 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Nle41
Top achievements
Rank 1
Nle41 asked on 10 Jul 2013, 08:06 AM
I m trying to expand and select related node on load on demand RadTreeView(telerik). but nodes are not expanded  if nodes are not loaded yet.I used the same codes  from

http://www.telerik.com/help/wpf/radtreeview-howto-exapand-select-item-with-lod-enabled-treeview.html

    var itemsControl = Tree as ItemsControl;
var itemFound = true;

    while (itemsControl != null && itemFound)
{
itemFound = false;
var currentObject = ObjList.FirstOrDefault();

for (int i = 0; i < itemsControl.Items.Count; i++)
{
var treeElement = itemsControl.Items[i] as TreeElement;
if (currentObject.Name == treeElement .Name)
{
itemFound = true;
networkObjList.RemoveAt(0);
BringIndexIntoView(itemsControl, i);
itemsControl.UpdateLayout();
var container = itemsControl.ItemContainerGenerator.ContainerFromIndex(i) as RadTreeViewItem;
if (container != null)
{
if (networkObjList.Count == 0)
{
container.IsSelected = true;
container.Focus();
}
else
{
container.IsExpanded = true;

}

container.UpdateLayout();
itemsControl = container as ItemsControl;
}
}
}
}

but non loaded nodes childs can not be filled. Why? could you help me?

And also I wonder that How does a container know when a child has loaded?

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 15 Jul 2013, 09:13 AM
Hi,

I see you are using an article from our help that has not been properly updated through the years. We are very sorry for caused inconvenience and shall update the article to describe the best and most straightforward approach.

Meanwhile, I would like to suggest you use the BringPathIntoView feature of RadTreeView. You could find more info in the following article. The basic idea is to provide a full path from root to required item and RadTreeView will perform necessary expand and scroll operations in order to bring the item into view.
Additionally if you would like to select the item the best approach would be to use a binding to the IsSelected property as described in the following article.
Finally, I see you would like to use load on demand. This feature is targeting the scenario when user hits the expand arrow of particular item and the item currently does not have any children with concerns to performance. This will give the developer a chance to lazy load the required items and notify back the RadTreeView that items has been loaded.
In addition, when you would like to programmatically navigate to some item that has not yet been loaded you would have to load it manually. The load on demand will not take care to properly load required items. I.e. you would have to manually fill the required items' children collections. Then, after the data item has been loaded in the appropriate place (in RadTreeView items source) you could call the BringPathIntoView method and select the item programmatically (using the IsSelected binding to the view model).

Don't hesitate to contact us should you need more info on the topic.

Regards,
Hristo
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TreeView
Asked by
Nle41
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or