The parse function of kendo.data.Model not triggered when create a new Model

2 posts, 0 answers
  1. qu
    qu avatar
    2 posts
    Member since:
    Nov 2013

    Posted 17 Dec 2013 Link to this post

    Hello, Kendo Team
      I'm studying Kendo UI Mobile data binding features and has a problem,when define a parse function for  kendo.data.Model  in "fields" section,the function has not triggered when create a new instance of the Model.
    var Person = kendo.data.Model.define({
        fields: {
            name: {
                editable: true,
                from:"name",
                parse:function(v){
                   console.log('parse name..., v=' + v);
                   return v;
                }
            },
            age:{
            type:"number"
            }
        }
    });
     
     
     
    var person = new Person( {
        name: "John Doe",
        age: 42
    });
    In above code,the parse function is not triggered when create a new Person.
    My question is:
    How about he parse function works, any advices for parse function usage?
  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 17 Dec 2013 Link to this post

    Hello,

    The parse function will be invoked when you try to set a field via the set method of the model e.g.

    person.set("name", "value");

    Regards,
    Atanas Korchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top