Grid not refreshing if there are any validation errors

7 posts, 0 answers
  1. Paul McNamara
    Paul McNamara avatar
    30 posts
    Member since:
    Apr 2010

    Posted 29 Jun 2011 Link to this post

    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.
  2. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 01 Jul 2011 Link to this post

    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
  3. DevCraft banner
  4. Paul McNamara
    Paul McNamara avatar
    30 posts
    Member since:
    Apr 2010

    Posted 01 Jul 2011 Link to this post

    I'll see what I can do as it's a reasonably complex scenario. Watch this space :)
  5. Paul McNamara
    Paul McNamara avatar
    30 posts
    Member since:
    Apr 2010

    Posted 05 Jul 2011 Link to this post

    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
  6. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 06 Jul 2011 Link to this post

    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!

  7. Sven J
    Sven J avatar
    26 posts
    Member since:
    Nov 2009

    Posted 09 Dec 2011 Link to this post

    Hi,

    are there any news about this?

    Thanks,
    Sven
  8. Paul McNamara
    Paul McNamara avatar
    30 posts
    Member since:
    Apr 2010

    Posted 09 Dec 2011 Link to this post

    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.
Back to Top
DevCraft banner