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

RadGridView.Items on Tab not populated until Grid visible

1 Answer 41 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kelly Wike
Top achievements
Rank 1
Kelly Wike asked on 22 Apr 2010, 03:55 PM
I have a DomainDataSource and I am binding its Data property to a RadGridView.ItemSource.  The grid is on a RadTabItem which is not selected until a user clicks on it.

 

 

<telerikGrid:RadGridView IsReadOnly="True" AutoGenerateColumns="False" FrozenColumnCount="1" ItemsSource="{Binding ElementName=resultDetailDomainDataSource,Path=Data}"

 

 

DataContext="{Binding}" Name="gridDetails" DataLoadMode="Synchronous">

 


The DomainDataSource data is loaded when the page loads and the data is in the DomainDataSource.Data property, but the GridView.Items collection is empty until the UI shows the grid ( i.e. user clicks on the tab item containing the grid).  Once the user clicks the tab and the grid is shown, it loads the Items collection fine.

How do I force the Items collection of the RadGridView to pick up the data before the user selects the tab item?  I need to get to the data through the RadGridView because of information that is in the columns collection.

I tried setting focus and using AutomationPeers to programatically select the tab, but was not successful.

1 Answer, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 28 Apr 2010, 08:17 AM
Hi Kelly Wike,

Current RadGridView will not update its Items collection until the first layout pass which causes problems in such scenarios but we will fix this behavior very soon. 

For the time being you can try two workarounds. The first involves creating and binding the RadGridView in code first - in this scenario the grid will automatically update its Items collection.

1.<Grid x:Name="gridViewHost">
2.      
3.</Grid>

1.RadGridView grid = new RadGridView();
2.grid.ItemsSource = Club.GetPlayers();
3.// at that point Items will be populated
4.this.gridViewHost.Children.Add(grid);

The other workaround, which might be more suitable to your scenario, is to just measure the grid manually and force the creation of items:

1.this.playersGrid.ItemsSource = Club.GetPlayers();
2.this.playersGrid.Measure(new System.Windows.Size(500, 500));


Greetings,
Milan
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.
Tags
GridView
Asked by
Kelly Wike
Top achievements
Rank 1
Answers by
Milan
Telerik team
Share this question
or