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

5 posts, 0 answers
  1. Sharada
    Sharada avatar
    43 posts
    Member since:
    Mar 2009

    Posted 16 Dec 2010 Link to this post

    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.
  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 16 Dec 2010 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Sharada
    Sharada avatar
    43 posts
    Member since:
    Mar 2009

    Posted 17 Dec 2010 Link to this post

    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
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 22 Dec 2010 Link to this post

    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
  6. Sharada
    Sharada avatar
    43 posts
    Member since:
    Mar 2009

    Posted 27 Dec 2010 Link to this post

    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

Back to Top
UI for WPF is Visual Studio 2017 Ready