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

Complex filtering in GridFilterCell

11 Answers 617 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
IT Dept
Top achievements
Rank 1
IT Dept asked on 28 Mar 2019, 02:54 PM

Is there any way to implement more complex filtering with a customer GridFilterCell (https://www.telerik.com/kendo-react-ui/components/grid/api/GridFilterCell/) component?

Currently it fires an OnChange event to the column but can only pass one operation and value to the column, which I presume then translates that to a FilterDescriptor. But is there a way (or a plan on the roadmap) to just pass a FilterDescriptor instead, so one could create a custom FilterCell that returns rules of the type "this value OR this value".

The FilterDescriptor objects are quite flexible and powerful, but the GridFilterCell has no way to tap into that flexibility that I can currently see.

Examples would be things like making a GridFilterCell with a Toggle between MondayWednesdayFriday and TuesdayThursday for a field showing day of the week, or other different groups of values in an enum column. But currently You can only pass a single operation of Equals or Contains or Greater than, so you could pick an individual weekday, but not something more complicated like a "Hide Weekends" button.

11 Answers, 1 is accepted

Sort by
0
IT Dept
Top achievements
Rank 1
answered on 28 Mar 2019, 02:55 PM
IF the GridFilterCell onChange could just return a FilterDescriptor and/or CompositeFilterDescriptor instead of a single operation there would be a lot more flexibility.
0
Stefan
Telerik team
answered on 29 Mar 2019, 07:12 AM
Hello, Eric,

Based on the provided details I can assume that the desired result is to pass more than one filter from a custom filter cell.

This can be achieved, by directly calling the method that filters the data with the programmatically built filter, instead of using the onChange event.

A similar approach is used in the following example:

https://stackblitz.com/edit/react-bjlym3?file=app%2FdropdownFilterCell.js

Please take a look and the example and advise if this is what's required to achieve the desired result.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
IT Dept
Top achievements
Rank 1
answered on 29 Mar 2019, 01:26 PM
That looks like a promising start, though there are some issues with entering one filter clearing the others which will have to be handled as well. I'll see if I can get it working acceptably.
0
Stefan
Telerik team
answered on 01 Apr 2019, 06:55 AM
Hello, Eric,

I`m glad to hear that this will help at least to start the prototype.

If additional assistance is needed during the process please let me know, I will be happy to help.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
IT Dept
Top achievements
Rank 1
answered on 25 Apr 2019, 12:11 PM
Hi,

We ran into some more issues related to trying to implement some more reusable custom filter cells. Mainly, we have to rewrite the logic for merging in the filters for each new data set we wish to use it on. Especially where we need to be able to filter multiple columns at once, this can get quite cumbersome and verbose. 

From our perspective, it seems like it would make more sense to let the filterChange function take a full FilterDescriptor, as the library seems to already handle those quite easily and could probably save a lot of code and help make these components more reusable. We feel like an API change like that would greatly improve how these custom filter cells work.
0
Stefan
Telerik team
answered on 26 Apr 2019, 06:30 AM
Hello, Eric,

Thank you for the recommendation.

I can suggest making a request in our feedback portal explaining how the filter change is expected for handle this. Then our developers will evaluate it to ensure that it will not affect to already implemented functionalities:

https://feedback.telerik.com/kendo-react-ui/ 

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
IT Dept
Top achievements
Rank 1
answered on 26 Apr 2019, 01:48 PM

I started one here:

https://feedback.telerik.com/kendo-react-ui/1406756-allow-setting-compositefilterdescriptor-from-gridfiltercell

0
Stefan
Telerik team
answered on 29 Apr 2019, 06:40 AM
Hello, Eric,

Thank you for sharing the request.

I have updated your Telerik points for posting this request.

Regards,
Stefan
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
IT Dept
Top achievements
Rank 1
answered on 10 Sep 2019, 05:00 PM

In case anyone ends up here via searching, the custom filter cell can actually use a function with complex logic to achieve more nuanced filter behaviour. An example is shown here of the Value containing multiple fields and an operation function being defined instead of simple value and string:

 

https://www.telerik.com/kendo-react-ui/components/grid/filtering/#toc-custom-filter-cells

0
IT Dept
Top achievements
Rank 1
answered on 10 Sep 2019, 07:12 PM
Actually... that doesn't work if you're using an MVC backend and server-side filtering. It attempts to pass the javascript function to the backend, which might work if you had a node backend and didn't mind running random code on your server, but doesn't help craft an EF query from custom frontend logic the same way the CompositeFilter does.
0
Vasil
Telerik team
answered on 12 Sep 2019, 10:59 AM
Hi Eric,

The Grid itself does not create your query, If you have some complex filter component, it will be needed to translate it to the query before making the request.

You can place anything in the filter cell and bypass the entire grid filter event and grid filter prop.


Regards,
Vasil
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
General Discussions
Asked by
IT Dept
Top achievements
Rank 1
Answers by
IT Dept
Top achievements
Rank 1
Stefan
Telerik team
Vasil
Telerik team
Share this question
or