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

How to validate a Kendo DataSource

2 Answers 91 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Greg
Top achievements
Rank 1
Greg asked on 11 May 2015, 05:29 PM

We use the kendo datasource sync feature for our crud operations and want to validate on or before sync gets called. It looks like your validation story is built around the UIValidator, which doesn't really work for us, we want to validate in code. I would expect that since you can define a schema for your model that the datasource would run through validation on or before sync but this doesn't seem to be the case. Am I missing something? How can I validate the datasource before I call sync?

 

Thanks,

Gregory Bailey

Advent Software, Inc.

2 Answers, 1 is accepted

Sort by
0
Greg
Top achievements
Rank 1
answered on 11 May 2015, 08:11 PM
Here is an example of what I am trying to do, code was lifted from Telerik's examples and then I added in validation and a validator. http://jsfiddle.net/gregpasha/m3hgayao/
0
Alexander Valchev
Telerik team
answered on 13 May 2015, 11:17 AM
Hi Greg,

Your observation is correct, Kendo UI Validator is an UI validator. The DataSource does not have build-in data validator. The validate settings that you set in the schema are applicable only for widgets with a build-in editor mode (e.g. they will not work with custom/template editors). The reason is that the UI validator works on the basis of validation attributes. When a custom editor is used, there is no way for the framework to know how the HTML will look like and respectively where to append the validation HTML attributes.

In your particular scenario, in order the validation to work as expected you should manually add required and name attribute to the editor input:
<li>
    <label>Name</label>
    <input type="text" id="products" class="k-textbox" name="ProductName" data-bind="value: ProductName" required/>
</li>

I hope this information will help.

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