Validation using the dataSource schema model in a ListView

4 posts, 0 answers
  1. Shane
    Shane avatar
    5 posts
    Member since:
    Feb 2012

    Posted 14 May 2012 Link to this post

    I'm having issues setting up validation on the dataSource's schema.model.fields object. I am following the documentation at: http://www.kendoui.com/documentation/framework/datasource/configuration.aspx as a guide.  It seems that the validation never fires.
     Below is the data source's schema property:
    model{
                    id"ID",
                    fields{
                        Name{
                            editabletrue,
                            nullabletrue,
                            validation {
                                required:true,
                                customRulefunction(input){alert('bad data');}
                            }
                        }
                    } 
    I would expect that this would mark the field as required, and prevent the form from submitting and then also pop up an alert. 

    I have created a jsfiddle with some sample code at:
    http://jsfiddle.net/sholder/RxLWS/ 
    any guidance on what I have wrong would be most appreciated.

    Thanks,
    Shane Holder
  2. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 17 May 2012 Link to this post

    Hi Shane,

    As the ListView is using templates, you should manually decorate the html elements with the appropriate validation attributes. An example of how to use ListView widget editing can be found here.

    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Shane
    Shane avatar
    5 posts
    Member since:
    Feb 2012

    Posted 17 May 2012 Link to this post

    Thanks for the information Rosen.  Does this mean that it is not possible to combine using a template and the model property of a schema in a ListView?  I was hoping to keep a separation between the validation code and the html, and generate the validation code for the model by using the DataAnnotations on my .Net model.

    Thanks,
    Shane Holder
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 18 May 2012 Link to this post

    Hi Shane,

    I'm afraid that as the developer is in charge of template creation, elements cannot be automatically decorated using the model definition.

    All the best,
    Rosen
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready