Changing Model id field's defaultValue?

2 posts, 0 answers
  1. Troy
    Troy avatar
    31 posts
    Member since:
    Sep 2015

    Posted 15 Nov 2016 Link to this post

    My back-end prefers a null value in the primary key for adding new records, but kendo uses 0 for numeric fields. If I change the "defaultValue" for a numeric model field that is defined as the 'id' field for the model, will this cause any problems with create operations or anything else that deals with new instances of the model?  Model has a "isNew" function, so it looks like things should work even if the defaultValue is changed from the normal zero value, I just wanted to be sure in the real world there won't be any nasty side-effects or anything that explicitly compares to zero instead of relying on isNew().  So:

    var dataSource = new{
      schema: {
        model: {
          id: "dbID"
             dbID: {type:"number", defaultValue:null},


  2. Rosen
    Rosen avatar
    3247 posts

    Posted 17 Nov 2016 Link to this post

    Hello Troy,

    Indeed, it should be OK to change the defaultValue to null. However, for your scenario it might be sufficient to just set the nullable option to true. This will bypass defaultValue assignment  altogether and leave the field value undefined. 

    Telerik by Progress
    Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Back to Top