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

Focus on particular Row (child node) on page load.

4 Answers 175 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Sharada
Top achievements
Rank 1
Sharada asked on 16 Dec 2010, 10:28 AM
Hi Telerik Team,

I am working on TreeViewList. When page is loaded, the default focus goes to first parent node. Can I set focus on a particular row (child node) on PageLoad? So that user will not need to drill down to that row.

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 16 Dec 2010, 12:38 PM
Hi Sharada,

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
Browse the videos here>> to help you get started with RadControls for WPF
0
Sharada
Top achievements
Rank 1
answered on 17 Dec 2010, 06:15 AM
Hi 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
0
Veselin Vasilev
Telerik team
answered on 22 Dec 2010, 02:51 PM
Hello Sharada,

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
Browse the videos here>> to help you get started with RadControls for WPF
0
Sharada
Top achievements
Rank 1
answered on 27 Dec 2010, 03:13 PM
Thanks for the reply.
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

Tags
TreeListView
Asked by
Sharada
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Sharada
Top achievements
Rank 1
Share this question
or