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

Grid filter operator issue

3 Answers 46 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 29 Sep 2020, 02:51 PM

Hello,

I am experiencing an issue when applying a filter operator on a Kendo Grid (inline filtering).

This issue only occurs when the filter operator on a column is first changed. Subsequent changes work as expected.

 

On a Kendo Grid having at least one column of type string, with a default filter operator of, for example "eq" set, if I select a different operator and type a value in the filter cell, the GridComponent.filterChange event fires with the correct value, but the initial operator of "eq". Subsequent changes of the operator work as expected.

If instead I type in a value for the filter first, then select a different operator, it works as expected on the first try.

How may I obtain a filterChange event when first selecting a different filter operator, without necessarily typing something into the filter cell first?

3 Answers, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 01 Oct 2020, 09:12 AM

Hi Mike,

Thank you for the provided details. Indeed, the reported behavior of the filtering functionality is as expected. Let me provide a bit more details. The (filterChange) event is fired when a valid FilterDescriptor has been applied to the Grid. If an operator such as "eq" or "contains" is selected then some value would be required to be set as well in order for the (filterChange) event to fire. If an operator such as "isempty" or "isnull"  is selected then the (filterChange) will fire as a value isn't required in these cases to apply the filter. Here is an example demonstrating that functionality:

https://stackblitz.com/edit/angular-zhaybv?file=app/app.component.ts

What could be done in order to avoid the default behavior of the filter row is to create a custom filter row component as demonstrated in the following article:

https://www.telerik.com/kendo-angular-ui/components/grid/filtering/reusable-filter/#toc-row-filtering

Such approach leaves the control in the hands of the developer to create the layout of the desired filter and to decide when to update the applied filter to the Grid as demonstrated in point 7 of the referenced article above. In your case, once the operator is changed it would be required to construct and apply manually the desired FilterDescriptor to use the selected operator and add a value that is probably set to an empty string. 

Regards,
Svetlin
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/.

0
Mike
Top achievements
Rank 1
answered on 01 Oct 2020, 10:13 AM

Hi Svetlin,

Thank you for the resources and the explanation. 

However, I must ask for clarification - is it expected behaviour that, after changing the default operator and subsequently typing in a value, the filterChange event is fired with the correct value but with the initial (default) operator, even though if one clicks the operator menu button one can see that it is showing a different operator selection than the one provided in the filterChange event arguments?

0
Svet
Telerik team
answered on 05 Oct 2020, 07:10 AM

Hi Mike,

What you describe is indeed an improper behavior. However, the Grid doesn't seem to function in this way. If the default operator is changed and then some value is entered the Grid emits a (filterChange) with the latest selected operator. Please check the following example demonstrating that behavior:

https://stackblitz.com/edit/angular-zhaybv-4u5iul?file=app/app.component.ts

Here is a video demonstrating the functionality of the Grid when changing the default filter operator and entering some value for the filter:

https://screencast-o-matic.com/watch/cY6hiVKrsi

The example handles the (dataStateChange) event which is fired on each data operation including filtering. Handling the (filterChange) would return the same filter object as the one corresponding to the filter property of the state emitted by the (dataStateChange) event.

If the behavior is different in your use - case scenario, then there should be something that is differently configured than the implementation demonstrated in the provided example. Thus, could I ask you to provide some more details that will help us to reproduce the reported undesired behavior. Thank you for cooperating. We are looking forward to your reply. 

Regards,
Svetlin
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/.

Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Svet
Telerik team
Mike
Top achievements
Rank 1
Share this question
or