This is a migrated thread and some comments may be shown as answers.

Nullable boolean fields are always converted to true or false

1 Answer 660 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 26 Jul 2012, 04:46 PM
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

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 27 Jul 2012, 07:15 AM
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!
Tags
Data Source
Asked by
Matt
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or