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

GridView Validation Preventing User From Making Changes

5 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rebecca
Top achievements
Rank 1
Rebecca asked on 20 Sep 2013, 03:12 PM
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

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 25 Sep 2013, 01:58 PM
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 >>
0
Rebecca
Top achievements
Rank 1
answered on 27 Sep 2013, 02:07 PM
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

0
Dimitrina
Telerik team
answered on 27 Sep 2013, 03:29 PM
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 >>
0
Rebecca
Top achievements
Rank 1
answered on 27 Sep 2013, 04:01 PM
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
0
Dimitrina
Telerik team
answered on 30 Sep 2013, 08:22 AM
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 >>
Tags
GridView
Asked by
Rebecca
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Rebecca
Top achievements
Rank 1
Share this question
or