Disable filter on hidden column

1 Answer 116 Views
Grid
Анатолий
Top achievements
Rank 1
Анатолий asked on 26 Oct 2021, 05:56 PM

Hello.

In kendo-grid I need to switch off filters on columns that user is hiding.

I tried to get field names from columns in ColumnVisibilityChangeEvent and then find them in grid filter. But there can be situations when in column and in filter there are different fields. For example - in column "StatusName" and in filter - "StatusId". Is there a way to solve this problem? How can I know filter field name in columnVisibilityChange?

1 Answer, 1 is accepted

Sort by
0
Martin Bechev
Telerik team
answered on 29 Oct 2021, 01:36 PM

Hello Anatoliy,

The most straight-forward approach is to check the field of the columns whose visibility is changed is to iterate the returned columns and check the field property:

 <kendo-grid
            (columnVisibilityChange)="onColChange($event)"
...
>
...
 </kendo-grid> 
 onColChange(e: ColumnVisibilityChangeEvent) {
    e.columns.forEach((col:any) => {
      console.log(col.field);
    });
  }

Please keep in mind that the field property is not part of the ColumnBase object thus any type needs to be used in this case.

Regards,
Martin
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Анатолий
Top achievements
Rank 1
commented on 03 Nov 2021, 03:00 PM

I know about this. And how can I get a filter field name for this column?
Martin Bechev
Telerik team
commented on 08 Nov 2021, 08:43 AM

Hi Anatoliy,

I am not sure that I understand correctly the use case.

What I could suggest is to log the returned ColumnVisibilityChangeEvent and check which properties are available when the event is triggered.

Regards,
Martin
Progress Telerik

Tags
Grid
Asked by
Анатолий
Top achievements
Rank 1
Answers by
Martin Bechev
Telerik team
Share this question
or