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

Bound collection data doesn't appear when the object instance that owns the collection changes

4 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 14 Nov 2011, 09:36 PM
I have a RadGridView bound to a collection that is owned by an object on the viewmodel that can change instances at runtime. When the app launches, it populates this collection for each of the instances of this class.

<telerik:RadGridView ItemsSource="{Binding SelectedProject.StandardProjectMilestones}" Grid.Row="0" x:Name="StandardMilestonesGridView"... />

My ViewModel implements the INotifyPropertyChanged "OnPropertyChanged" on the "SelectedProject" property. The "SelectedProject" is a "Project" object, which also implements "OnPropertyChanged" on the "StandardProjectMilestones" property, which is of type QueryableCollectionView. This collection is filtered from an Autoloading QueryableDomainServiceCollectionView of a RIA-loaded Enity Set. The grid gets populated with the initial "SelectedProject"'s collection, but when the "SelectedProject" is set to a different Project instance, whose "StandardProjectMilestones" collection has been pre-populated as I said, the collection data does not appear in the GridView - it just displays an empty grid. Even when the project is set back to the original Project, the grid remains empty. I tried repopulating the collection when the SelectedProject changes, but the same behavior occurs. Is there a re-binding that I need to do to get the grid to populate with the collection data when the object intance is reset? If so, how? Or is my design faulty somehow?

I should mention that in debugging I have verified that every Project's collection has items in it, they just don't show up on the gridview.

Thank you,
 
-Thomas
 

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 15 Nov 2011, 10:01 AM
Hello Thomas,

Have you tried calling the RadGridView.Rebind() method?

Regards,
Ross
the Telerik team

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

0
Thomas
Top achievements
Rank 1
answered on 15 Nov 2011, 08:51 PM
Thanks for your suggestion. That made matters worse. In the code behind for my view, I subscribed to an event published when the SelectedProject changes, and in the function for the event I put the call to Rebind(). Now the data doesn't even show up for the initial selected Project. Again, the collection itself is populated with items.

Can you try to reproduce my design and if it works for you, attach an example?

Thank you.
0
Rossen Hristov
Telerik team
answered on 16 Nov 2011, 05:02 PM
Hi Thomas,

Can you please send us a small dummy project that reproduces your setup and this behavior. Thanks.

Greetings,
Ross
the Telerik team

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

0
Thomas
Top achievements
Rank 1
answered on 17 Nov 2011, 09:36 PM
I have been able to work around it for now and I can't take time at the moment to write up a dummy project to present the behavior. I didn't mention that for various reasons I did not have a foreign key relationship defined for this - I used a linq query to populate the project's collection. My work-around is to force a foreign key relationship between them at the entity level and now it works. For this application I would have preferred not to have to do that because the data is from two disparate sources (I had to jerry-rig the FK setup). But for now it is working properly. When I have time I will reproduce the issue for your examination, but perhaps it is a low-risk issue (if it is a real issue) due to my unusual situation? In most cases a FK relationship is a no-brainer I guess.

Thank you.
Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or