GridView Validation Preventing User From Making Changes

6 posts, 0 answers
  1. Rebecca
    Rebecca avatar
    28 posts
    Member since:
    Nov 2010

    Posted 20 Sep 2013 Link to this post

    Hi,

    I am having a problem with the GridView: if the row is marked invalid because a property is invalid, the user is unable to edit any other cell.

    Let's say I have a GridView that is letting me edit a class called Person that has 3 properties
    • Name: the person's name
    • Type: which allows the user to choose between Child or Adult
    • Age: that is validated according to the Person type (child is allowed to be between 1 - 19, adult is allowed to be between 19-120)

    Now, let's say the user adds a new Person and enters a name, selects child as the person type by accident and enters an age of 30. Because the Person is actually not a child, the age property becomes invalid and the row is set to invalid.

    At this point the user is not able to change the Type to Adult because they cannot leave the age field.

    This is particularly a problem if the user attempts to save a person without entering an age or type because the row becomes invalid, the type is not selected and the field that the user is stuck in is the Age field. They cannot edit the type column and so the age is always going to be invalid.

    How do I get around this?

    Thank you,

    -Rebecca

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Sep 2013 Link to this post

    Hi Rebecca,

    Would you please try setting

    ValidatesOnDataErrors="InViewMode" 
    for RadGridView? That way the validation should still be displayed in View mode, but you will be able to edit another field to make the values valid.
     
    Let me know how this works for you.

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. Rebecca
    Rebecca avatar
    28 posts
    Member since:
    Nov 2010

    Posted 27 Sep 2013 Link to this post

    Thank you for your reply Didie,

    For testing purposes I put set my grid's ValidatesOnDataErrors="InViewMode" and discovered quickly why we aren't using this mode. We are not using ValidatesOnDataErrors="InViewMode" because it takes too long to load the data in the grid when we do this.

    -Rebecca

  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 27 Sep 2013 Link to this post

    Hi Rebecca,

    Do you rely on those validation errors to stay as you move to another cell? You can set 

    ValidatesOnDataErrors="None". How does this work for your scenario? 
    
    

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  5. Rebecca
    Rebecca avatar
    28 posts
    Member since:
    Nov 2010

    Posted 27 Sep 2013 Link to this post

    Didie,

    Thank you for your suggestion. Based on it I was able to come up with a work-around. I am not 100% happy with the solution that I came up with but at least the user can use the grid as intended.

    This is what I did:
    • I have set the Grid's ValidatesOnDataErrors="None" unless my code detects that there is a validation error.
    • In the case when my code detects a validation error I am setting the ValidatesOnDataErrors="InViewMode" so that the errors are displayed to the user.

    The reason I don't like this is because:

    1. The user is not displayed errors when they leave the row and are only shown errors upon attempting to save their work
    2. Changing the grid to use ValidatesOnDataErrors="InViewMode" causes every item in the grid to validate and this takes a long time. I know which item is invalid...I just can't tell the grid that.

    I would love it if there was a better solution.

    Thanks again,


    -Rebecca
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 30 Sep 2013 Link to this post

    Hello Rebecca,

    Thank you for the update.

    I understand your concern, still those are the validations mode options that we can suggest.
     

    Regards,
    Didie
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top