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

Is ChildrenOfType<GridViewRow> Broken?

2 Answers 150 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 27 May 2011, 03:48 PM
I am using the latest internal build and even though the following comes back with 2:

int gridRowCount = _rgvwBreakpoints.Items.ItemCount;

This only comes back with the new row:

var rows1 = _rgvwBreakpoints.ChildrenOfType<GridViewRow>();

And this comes back with the header row, the new row, and the footer row:

var rows = _rgvwBreakpoints.ChildrenOfType<GridViewRowItem>();

This always comes back with null:

GridViewRowItem gridViewRow1 = _rgvwBreakpoints.ItemContainerGenerator.ContainerFromIndex(0) as GridViewRowItem;

Even though this loops through twice, I get null values as well:

foreach (var item in _rgvwBreakpoints.Items)
{
   var currentRow = this._rgvwBreakpoints.ItemContainerGenerator.ContainerFromItem(item);
}

It doesn't seem to matter what I have Virtualization (Row and Column) set to.

2 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 28 May 2011, 07:40 AM
Hi Randy,

I have just tested it with 2011.1.526 binaries and it works as expected (the test project is attached for your reference). Are you sure that your RadGridView has already loaded the data properly at the time you are invoking ChildrenOfType<GridViewRow>() ?

Kind regards,
Ivan Ivanov
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
Randy
Top achievements
Rank 1
answered on 31 May 2011, 07:36 AM

It seemed to work when I changed the code as follows:

 

 

 

 

GridViewRow row = (GridViewRow)grid.ItemContainerGenerator.ContainerFromItem(item);

 

 

 

 

if (row == null)

 

 

{

 

 

 

 

 

 

grid.UpdateLayout();

 

 

grid.ScrollIntoView(item);

 

row = (

 

GridViewRow)grid.ItemContainerGenerator.ContainerFromItem(item);

 

 

}

Tags
GridView
Asked by
Randy
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Randy
Top achievements
Rank 1
Share this question
or