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

The Grid validation will not be fired if change from a invalide value to the old valid value

1 Answer 540 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Konrad
Top achievements
Rank 1
Konrad asked on 19 May 2016, 02:36 PM

the problem willl occurs when the editable attribut of the grid is set to "inline" oder "popup".

If i change the value for a field, so it is not valid anymore, the validation message will be shown. When I change the filed back to the original valid value, the validation error is still displayed. The validation function is not called. If i set a break point on the custom validation function in the browser developer tools, the break point will not be arrived in this situation.

You can reproduce it with the "Grid / Custom validator editing" Demo

Steps:

  1. Press Edit. The row will be editable
  2. Write "A" in the field ProductName. The field will be valid.
  3. Write "a" in the field ProductName. The field will be invalid and the validation message "Product Name should start with capital letter" is shown.
  4. Write "A" in the field ProductName. The field will be valid but the validation message is still shown.

The same thing with the Fild "Unit Price" which have noch custom validation rather is set to "required"

Steps:

  1. Press Edit. The row will be editable
  2. Write 1 in the field Unit Price. The field will be valid.
  3. Clear the field Unit Price. The field will be invalid and the validation message "Unit Price is required" is shown.
  4. Write 1 in the field Unit Price. The field will be valid but the validation message is still shown.

What can I do to validate the fields right in this situation?

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 23 May 2016, 08:55 AM
Hello Konrad,

The issue comes from the fact that the editing functionality does not update the model when the value is not valid. Hence when the old one is returned, the model sees that it is the same and doesn't trigger validation again.

The solution that I can suggest is to validate the form manually either on input blur or on form save. Basically, you will need to get a reference to the Kendo UI Validator in the grid edit event and call its validate method when it is appropriate:
Regards,
Georgi Krustev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Konrad
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or