filter checkbox column

1 Answer 911 Views
Grid
jan
Top achievements
Rank 1
Iron
jan asked on 08 Oct 2021, 06:48 AM

Hi,

I have a grid with this config:

<kendo-grid
    [kendoGridBinding]="gridData.data"
    [filterable]="true"
    (add)="addHandler()"
  >

In this grid I have a checkbox column:


<kendo-grid-column field="defaultLang" title="Alapértelmezett">
      <ng-template kendoGridCellTemplate let-dataItem>
        <div style="text-align: center">
          <input type="checkbox" disabled [checked]="dataItem.defaultLang" />
        </div>
      </ng-template>
    </kendo-grid-column>

If I want to filter this column I get an error, because the filter mechanism operates on strings. How can I

make this work, that I can filter it with '0', '1', 'true', 'false'?

 

Thanks.

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Bechev
Telerik team
answered on 12 Oct 2021, 10:34 AM

Hello Jan,

The most straightforward approach to filter the checkbox column is to set the filter option of the <kendo-grid-column> component to boolean

<kendo-grid-column field="defaultLang" title="Alapértelmezett" filter="boolean">
      <ng-template kendoGridCellTemplate let-dataItem>
        <div style="text-align: center">
          <input type="checkbox" disabled [checked]="dataItem.defaultLang" />
        </div>
      </ng-template>
 </kendo-grid-column>

Here is an example:

https://stackblitz.com/edit/angular-6xnu6i

I hope this helps.

Regards,
Martin
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

jan
Top achievements
Rank 1
Iron
commented on 12 Oct 2021, 12:17 PM

Thanks, it worked like a charm. I wasn't aware of this feature.
Tags
Grid
Asked by
jan
Top achievements
Rank 1
Iron
Answers by
Martin Bechev
Telerik team
Share this question
or