Grid filter operator issue

4 posts, 0 answers
  1. Mike
    Mike avatar
    11 posts
    Member since:
    Oct 2008

    Posted 29 Sep Link to this post

    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?

  2. Svetlin
    Admin
    Svetlin avatar
    444 posts

    Posted 01 Oct Link to this post

    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/.

  3. Mike
    Mike avatar
    11 posts
    Member since:
    Oct 2008

    Posted 01 Oct in reply to Svetlin Link to this post

    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?

  4. Svetlin
    Admin
    Svetlin avatar
    444 posts

    Posted 05 Oct Link to this post

    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/.

Back to Top