GridViewDataColumn Filter and Contains

1 Answer 35 Views
GridView
Pavel
Top achievements
Rank 1
Pavel asked on 16 Dec 2024, 10:57 AM | edited on 16 Dec 2024, 11:57 AM

Hi!
I have a filter with values ​​set (via DistinctValuesLoading). There is a string property in the elements. Is there a way to use "Contains" when filtering elements.

I used a CustomFilteringControl:

var ids = this.distinctValuesListBox.SelectedItems.OfType<string>();
this.filterDescriptor = new FilterDescriptor<RowInfo>()
{
    FilteringExpression = rowInfo => ids.Any(x => rowInfo.Name.Contains(x))
};
gridView.FilterDescriptors.Add(this.filterDescriptor);     

 

It works. But I can't use RadGridView settings saving. And for each column (in different tables) where such mechanics will be used (unique values ​​will be different) it will be necessary to create its own CustomFilteringControl and add it to ICustomPropertyProvider to save RadGridView settings.

 

Is there a way to set the filtering method to "Contains"?

Something like this:
DistinctValuesSearchMode="Contains"

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 17 Dec 2024, 10:41 AM

Hello Pavel,

There is no "Contains" option for the distinct values in the default FilteringControl. To achieve your requirement you should write custom logic, as you are already doing.

To save the settings of the custom filtering control you should write also custom persistence behavior.

I have prepared a small sample showing one way to implement a custom FilteringControl showing only distinct values and that can be used for different columns. The example shows also how to serialize these settings. I hope this helps.

Regards,
Martin Ivanov
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.

Tags
GridView
Asked by
Pavel
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or