4 Answers, 1 is accepted
You can select the item you want in the DataLoaded event and then unsubscribe from it:
public
MainWindow()
{
InitializeComponent();
this
.RadTreeListView1.DataLoaded +=
new
EventHandler<EventArgs>(RadTreeListView1_DataLoaded);
}
void
RadTreeListView1_DataLoaded(
object
sender, EventArgs e)
{
this
.RadTreeListView1.SelectedItem =
this
.RadTreeListView1.Items[2];
this
.RadTreeListView1.DataLoaded -=
this
.RadTreeListView1_DataLoaded;
}
Hope this helps.
Kind regards,
Veselin Vasilev
the Telerik team
I got your answer. But I think, this will be useful if I need to focus on parent (root) node.
this
.RadTreeListView1.SelectedItem =
this
.RadTreeListView1.Items[2];
If I need to focus on child node, then what should be done? I need to focus on particular child node while page is loading. And also the focused child node should be expanded. Please reply.
Thanks
You need to expand all the parents of that node first. Use the ExpandHierarchyItem(item) method of the treelistview. To be sure to call it when all the data is loaded you can subscribe to LayoutUpdated event and execute the logic there. After that unsubscribe from that event (because it fires multiple times).
You can also use the ScrollIntoViewAsync method to scroll to the particular item.
All the best,
Veselin Vasilev
the Telerik team
Actually in our case, the data is loaded on demand i.e on click of a parent node.
private
void RadTreeListView1_RowIsExpandedChanging(object sender, RowCancelEventArgs e)
{
var row = e.Row as TreeListViewRow;
if (row.IsExpanded)
{
People_DC people = e.Row.Item as People_DC;
if (people != null && people.HasChild)
{
people.LoadChildren(people);
}
}
}
We are binding ItemSource to RadTreeListView
public ObservableCollection<People_DC> Items
Hence we don't have the entire data in order to set ExpandHierarchy. We are binding an observablecollection to radtreelistview which is being updated with new data on click of node.The new data in observable collection is not updated in UI i.e the treeviewitem are not expanded.
Is there any event available wherein it is possible to expand the desired row and focus it.?
Actually we are looking for similar functionality in RadTreeListView as described in below example but this is for TreeView
http://www.telerik.com/help/wpf/radtreeview-howto-exapand-select-item-with-lod-enabled-treeview.html