Custom FilterDescription in dynamic Grid

1 Answer 14 Views
Filter Grid
Johan
Top achievements
Rank 2
Iron
Iron
Johan asked on 26 Aug 2025, 08:25 AM
I have a Grid with dynamic number of column (using ExpandoObject) and I want to create a custom row filter with a single text input field that uses a kind of simple wildcard logic I've already written, like "joh*" and so on. My question is how I call my wildcard method. I've started out with a FilterCellTemplate and TelerikTextBox where I can capture ValueChanged and I have access to the new value and the FilterCellTemplateContext. But how to continue? I've search the website without much success. Is it possible to call my wildcard logic from a custom FilterDescriptor?
Johan
Top achievements
Rank 2
Iron
Iron
commented on 26 Aug 2025, 11:34 AM

I have managed to create an Expression<Func<ExpandoObject, bool>> expression which seems to work fine when I use it togeather with a Queriable List of ExpandoObject. But how do I add it as a FilterDescriptor or to the list of descriptors in cases where the user wants to filter on more columns than one? I've looked at context.FilterDescriptor.CreatefilterExpression(myExpression) but it throws an ArgumentException.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 26 Aug 2025, 01:24 PM

Hi Johan,

The FilterDescriptor supports a predefined collection of operators and the built-in .NET value types plus string. I am not sure what do you imply by "custom filter descriptor", but I'd say there is no such thing currently.

Custom filtering generally requires you to do one or both of the following:

  • Modify the Grid filter state by changing, adding or removing filter descriptors. You can either do that by using a filter template or through the Grid state (see the example "Override user actions ...").
  • Use OnRead and perform the filtering manually, based on args.Request.Filters. This means that you won't be able to use ToDataSourceResult(), or at least not for the filtering operations.

For example, if the user types "joh*", this is equivalent to (StartsWith joh) or (Contains joh). You will be using one FilterDescriptor in the column's CompositeFilterDescriptor.

If the user types "joh* foo", this is equivalent to (StartsWith joh AND Contains foo), so, you will be using at least two FilterDescriptors in the column's CompositeFilterDescriptor.

Overall, if you wish to check if it's possible to use the built-in Grid filter state, then you must be able to define the filter logic as groups or expressions in a Filter component. One Filter component instance represents one CompositeFilterDescriptor with all its nested descriptors.

Note that if the textbox in the filter template is bound to the column's first FilterDescriptor Value, then changing the Grid filter state will also change the textbox value, which may be unexpected to the user.

context.FilterDescriptor in the filter template is strictly for the current column. It's not possible to inject descriptors for other columns there. For this purpose you can use the options above (OnRead or the Grid state).

CreateFilterExpression() is not intended or recommended for general use. Its public accessor is an oversight on our part, and there is a logged task to revise it. Sorry about that.

Regards,
Dimo
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.

Johan
Top achievements
Rank 2
Iron
Iron
commented on 27 Aug 2025, 08:29 AM

Ok, thanks for the answer, I think I understand how to maybe approach what I want to do. I think OnRead may be my best bet.

In short what the customer wants to have (simply described) is a grid of List<List<string>> with the possibility to write regexp (or similar wildcard kind of expression) in an input-filter-textbox for each column. Also support for multiple sortmode. 

I hope this explains what I'm looking for to do.

 

Dimo
Telerik team
commented on 27 Aug 2025, 09:03 AM

Yes, regexp filtering or anything that cannot be translated to regular FilterDescriptors will require a custom filtering implementation in OnRead.

Multiple column sorting is a builtin feature in the Blazor Grid.

Tags
Filter Grid
Asked by
Johan
Top achievements
Rank 2
Iron
Iron
Answers by
Dimo
Telerik team
Share this question
or