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

2 posts, 0 answers
  1. Konrad
    Konrad avatar
    6 posts
    Member since:
    May 2011

    Posted 19 May 2016 Link to this post

    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?

  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3747 posts

    Posted 23 May 2016 Link to this post

    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!
     
Back to Top