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

Grid Filter fails on boolean data

2 Answers 1268 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 06 Sep 2012, 06:14 PM

My grid is defined by:
$('#formGrid').kendoGrid({
       dataSource: [
           { FormDesc: 'hello', FormID: 1, IsEnabled: true },
           { FormDesc: 'two', FormID: 2, IsEnabled: false }
       ]
       , columns: [
        { field: 'FormDesc', title: 'Form Name', width: 140 },
        { field: 'IsEnabled', title: 'Enabled', width: 40 }
       ]
       , filterable: true
       , resizable: true
       , scrollable: true
   });

If a user filters the column on Enabled the grid never returns. This appears to be caused by the boolean value of IsEnabled.

You can see this in the following jsfiddle: http://jsfiddle.net/berandorFiddle/wYQy2/1/ 

An obvious workaround is to convert my boolean to a string.  Is there a more elegant way to work around this?

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 11 Sep 2012, 02:04 PM
Hi Jim,

The problems comes from the fact that the type of dataSource fields is not declared. By default the fields are interpret as strings if the type is not specified explicitly. If you set up the field IsEnabled field as boolean the problem will disappear and the grid will display a filterable menu customized for boolean values.
schema: {
    model: {
        id: "FormID",
        fields: {
            FormDesc: {type: "string"},
            FormID: {type: "number"},
            IsEnabled: {type: "boolean"}
        }                       
    }
}

Please check the updated fiddle: http://jsfiddle.net/valchev/wYQy2/4/ 

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Stef Heyenrath
Top achievements
Rank 1
answered on 27 Nov 2012, 09:11 PM
See this fiddle which translates an enum to a string.

The question is : how to update the filter so that the 2 values are shown in the dropdownlist ?
Tags
Grid
Asked by
Jim
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Stef Heyenrath
Top achievements
Rank 1
Share this question
or