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

Grid not refreshing if there are any validation errors

6 Answers 182 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Paul McNamara
Top achievements
Rank 1
Paul McNamara asked on 29 Jun 2011, 08:18 PM
I have a scenario where the ItemsSource of a RadGridView (an ObservableCollection of view model objects) can change based on filter data. My problem is that if there are any validation errors (using IDataErrorInfo on the object bound to the column DataMemberBinding) in the grid at the time the underlying collection is updated the grid fails to refresh. I've even tried clearing all the errors in the view models before clearing the collection but the grid doesn't seem to pick up on the events that are fired as a result. This happens regardless of what I set the ValidatesOnDataErrors option to.

It looks to me like the grid only updates its internal state when the field exits edit mode and doesn't respond to the IDataErrorInfo events at all. Is this by design? If ValidatesOnDataErrors is set to InEditMode it also won't allow focus to leave the cell at all which is also a problem.

Is the failing to refresh from the ItemsSource if any validation errors exist also by design? If not does anyone know of a possible workaround? Can I manually clear the errors from the control itself? I'm trying to keep to MVVM so I'd prefer not to have to do that. Maybe there's a way to get it to requery the underlying collection?

The way errors are rendered visually when using this mechanism is really nice so I'd like to use it if possible.

6 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 01 Jul 2011, 09:17 AM
Hello Paul Mcnamara,

Could you please send me a sample project, which I can debug on my side?
Thank you in advance.

All the best,
Nedyalko Nikolov
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
Paul McNamara
Top achievements
Rank 1
answered on 01 Jul 2011, 10:08 AM
I'll see what I can do as it's a reasonably complex scenario. Watch this space :)
0
Paul McNamara
Top achievements
Rank 1
answered on 05 Jul 2011, 05:34 PM
Ok, I've done a bit more investigation and I've managed to solve one of the problems myself.

The problem where the rows would not change when I changed the underlying collection was my fault and it works fine (sorry).

The problem with the row style not updating if an error event is thrown is still an issue however and I've put together a little example app to demonstrate it.

In the example a grid loads up with some generated data bound to my view model's Rows property. If you click the "Generate Errors" button you will see Col 2 has its values updated to invalid ones (they must start with "Value" to be valid). When this happens the event defined by IDataErrorInfo is fired but you'll see that the visible rows don't take on the red invalid style. However if you scroll, any subsequently loaded rows do. This suggests that the error state is being evaluated on row load but the row is not actually subscribing to the event. This seems like a bug to me or at least a behaviour that could be controlled by an option.

It works fine if the error is caused by a direct edit in the grid but in my app various things can effect grid values behind the scenes so this is a bit of a show stopper at the moment.

The forum doesn't seem to want to let me upload a zip file (even if I rename it to .gif or whatever). If you email me I can send it in a reply if you wish.

Cheers,

Paul
0
Vlad
Telerik team
answered on 06 Jul 2011, 06:23 AM
Hi Paul,

 You can open support ticket and send us the project. 

All the best,
Vlad
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Sven J
Top achievements
Rank 2
answered on 09 Dec 2011, 10:17 AM
Hi,

are there any news about this?

Thanks,
Sven
0
Paul McNamara
Top achievements
Rank 1
answered on 09 Dec 2011, 10:50 AM
I ended up working around it to good effect by forcing the invalid rows to refire their IDataErrorInfo event after the Loaded event had fired for the RadGridView.
Tags
GridView
Asked by
Paul McNamara
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Paul McNamara
Top achievements
Rank 1
Vlad
Telerik team
Sven J
Top achievements
Rank 2
Share this question
or