How to validate a Kendo DataSource

3 posts, 0 answers
  1. Greg
    Greg avatar
    7 posts
    Member since:
    Apr 2013

    Posted 11 May 2015 Link to this post

    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?



    Gregory Bailey

    Advent Software, Inc.

  2. Greg
    Greg avatar
    7 posts
    Member since:
    Apr 2013

    Posted 11 May 2015 in reply to Greg Link to this post

    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.
  3. Alexander Valchev
    Alexander Valchev avatar
    2887 posts

    Posted 13 May 2015 Link to this post

    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:
        <input type="text" id="products" class="k-textbox" name="ProductName" data-bind="value: ProductName" required/>

    I hope this information will help.

    Alexander Valchev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top