Nullable boolean fields are always converted to true or false

2 posts, 0 answers
  1. Matt
    Matt avatar
    9 posts
    Member since:
    Mar 2012

    Posted 26 Jul 2012 Link to this post

    Hi there,

    I'm using a datasource with a grid an I need to be able to handle null values in boolean fields differently from false.  However, when the DataSource gets its data and runs through convertRecords() it converts all the boolean fields to true or false even if I've marked the field as nullable:true.  Is there a way to get around this and actually show nulls for boolean fields?

    Here's a JS fildde with a nullable boolean being converted to false: http://jsfiddle.net/mtrichards26/wCd4T/21/ 

    Thanks!
    Matt
  2. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 27 Jul 2012 Link to this post

    Hello Matt,

    As you may know the nullable options is used when a new item is created.
    However, you may change the way data types are converted by default by setting a parse method through the field's declaration. For example:

    IsTesting:{
        type:"boolean",
        parse: function(value) {
            if (value != null) {
                return value || false;
            }
            return value;
        },
        nullable:true                                       
    }

    Greetings,
    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