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

Last RowLoaded event?

6 Answers 210 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ramin
Top achievements
Rank 1
Ramin asked on 29 Oct 2010, 10:25 PM

Hi,
My Grid is loading its data by a user request. So when the Grid is loaded at the startup it is empty.
When the grid is loaded with data by a command that user selects I need to select the first row and set the focus to the first cell of that row. I am using RowLoaded event in this code to accomplish this:

private void SearchGrid_RowLoaded(object sender, RowLoadedEventArgs e)
{
    //Set the focus to first cell after the last row is loaded
    if (SearchGrid.ChildrenOfType<GridViewCell>().Count() > 0)
    {
        if (e.DataElement == SummaryList[SummaryList.Count() - 1])
        {
            SearchGrid.SelectedItem = SummaryList[0];
            SearchGrid.ChildrenOfType<GridViewCell>().First().Focus();
        }
    }
}

I am wondering if there is an event that tells me the Grid has finished its generating cells so I can set my focus at that time?

Thanks

6 Answers, 1 is accepted

Sort by
0
Build-dude
Top achievements
Rank 1
answered on 31 Oct 2010, 03:11 AM
I think you are looking for the DataLoaded event this fires after the grids itemsource is updated
0
Ramin
Top achievements
Rank 1
answered on 01 Nov 2010, 07:37 PM
No DataLoaded won't help because when it is triggerred no GridViewCell has been created yet so I cannot set the focus to that.
0
Vlad
Telerik team
answered on 02 Nov 2010, 08:09 AM
Hello Ramin,

Indeed DataLoaded + Dispatcher will do the work.

Regards,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ramin
Top achievements
Rank 1
answered on 02 Nov 2010, 04:48 PM
I tried to user Dispatcher in DataLoaded but it didn't work. Maybe I used it in a wrong way!
Please take a look at the attached image.
0
Vlad
Telerik team
answered on 03 Nov 2010, 09:53 AM
Hello,

 You can call UpdateLayout() to fix this. I've attached small example application. 

Best wishes,
Vlad
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ramin
Top achievements
Rank 1
answered on 03 Nov 2010, 07:21 PM
That worked out very well.
Thanks Vlad
Tags
GridView
Asked by
Ramin
Top achievements
Rank 1
Answers by
Build-dude
Top achievements
Rank 1
Ramin
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or