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

How to remove filter for boolean column

1 Answer 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 20 Jan 2017, 03:33 PM

I have a column on a grid that is a boolean value. The user has three filter choices; True, False or Show All (i.e. no filter). Because the column is boolean

    filter({ field: "fieldName", operator: "startswith",value: "" })

raises an exception. The boolean column won't accept a string in the filter on the server (uses Ajax).

How can the filter for the column be 'reset' (there may be other columns filtered, so any other filters are still needed)?

1 Answer, 1 is accepted

Sort by
0
Patrick | Technical Support Engineer, Senior
Telerik team
answered on 20 Jan 2017, 07:13 PM
Hello Kevin,

In order to set the filter of the DataSource so all Boolean Items are selected, use dataSource.Filter.  Then set the filter.logic property to "or", and include the boolean's true and false values inside filter.filters.
$("#grid").kendoGrid({
  dataSource: {
    ...
    filter:{
      logic: "or",
      filters: [
        { field: "Discontinued", operator: "eq", value: true },
        { field: "Discontinued", operator: "eq", value: false }
      ]
    },
    ...
  },
...
});

Please take a look at this Kendo UI Dojo by Progress which illustrates the above approach.  

I hope this helps!

Regards,
Patrick
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Kevin
Top achievements
Rank 1
Answers by
Patrick | Technical Support Engineer, Senior
Telerik team
Share this question
or