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

get gridviewrow from radgridvview

3 Answers 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dudy
Top achievements
Rank 1
Dudy asked on 23 May 2012, 10:05 AM
hi
i need to get spacific row in radgridview
 i tried this:
 foreach (var row in this.gridview1.ChildrenOfType<GridViewRow>())
                {                   
                    i++;
                    if (i == 200)
                    {
                        row.IsSelected = true;
                        territorymanagementactionitems.BringIndexIntoView(200);
                    }
                }

but after ~16 rows the debugger goes out from loop (i have more than 200 rows)

3 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 24 May 2012, 09:31 AM
Hello,

It is not a good idea to work with physical containers such as GridViewRow. When there is row virtualization, you would have only 10-20 rows (depending on the grid height) which are recycled and reused for different data items as the user scrolls up and down. So you don't have rows for every single data item. You only have rows for the visible items.

You should always try to work with data items and Bindings, instead of relying on physical containers such as the rows.

Regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Dudy
Top achievements
Rank 1
answered on 24 May 2012, 02:26 PM
if so , can you give me simple example how can i set focus on a spacific item ?(or row) 
0
Rossen Hristov
Telerik team
answered on 24 May 2012, 02:36 PM
Hi,

If that item is not in the view, you cannot set focus on it like that. You can use the ScrollIntoView method of RadGridView and then programmatically select the item. More about this you can learn here.

If you want to use your original approach with ChildrenOfType, you will have to turn off row virtualization so that all rows are created, i.e. not only 16 of them.

Regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Dudy
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Dudy
Top achievements
Rank 1
Share this question
or