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

Grid custom editor updates dataSource even when validation fails

2 Answers 106 Views
Validation
This is a migrated thread and some comments may be shown as answers.
azbola
Top achievements
Rank 1
azbola asked on 14 Nov 2013, 05:42 PM
Hi there,

I have a grid with a field with a custom editor.  This editor consists of an input field, and I have applied validation to this using the HTML5 attributes (required, min, etc). The field uses data-bind syntax to get/set the data.

This works correctly and I get an error message when updating the field with invalid values.  
However there appears to be a big flaw to how this works, the data-binding occurs BEFORE the validation it would seem.

Even if I enter an invalid value. the change event still fires on the dataSource and the new invalid value is set.  
This seems to me to be unwanted behaviour, if there is an invalid value I do not want this set in the datasource.

Is this by design? How can I stop the data source updating on a validation failure?

Thanks in advance,
David Asbury.

ps.  It is also possible to bypass the validator simply by pressing the escape key.  This kills the validation message and removes focus from the invalid control.   This also seems like a bug. 

2 Answers, 1 is accepted

Sort by
0
azbola
Top achievements
Rank 1
answered on 15 Nov 2013, 10:46 AM
Here is a jsFiddle that demonstrates this behaviour:
http://jsfiddle.net/YFqNC/51/

0
Rosen
Telerik team
answered on 15 Nov 2013, 04:49 PM
Hi azbola,

Thank you for providing the sample. The behavior you have described is caused by the value binding declaration. When binding is specified there should be no space between the value: and the field name. This is required as the validation is executed via the attribute name thus will not work as expected in this case.
Also you may know that there is no need to specify the value binding explicitly as the attribute will be generated automatically using the input element's name attribute. Here you can find a modified version of the jsfiddle you have sent us.

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Validation
Asked by
azbola
Top achievements
Rank 1
Answers by
azbola
Top achievements
Rank 1
Rosen
Telerik team
Share this question
or