Composite filter descriptor to find records that match two different columns.

1 Answer 44 Views
Grid
John
Top achievements
Rank 2
Iron
Iron
Iron
John asked on 13 Aug 2024, 02:45 AM

I'm trying to create filter that works on two columns. The first column "IsActive" = true works properly.

I need to have a second filter on a column that filters for all "ParticipantId" that is a nullable integer type
thatis either null or empty.

Logical this would be an And

Currently this is what I have but it does not work. How would I includea filter for a null integer column using AND logic?

var filterDescriptors = new List<IFilterDescriptor> { new CompositeFilterDescriptor{ FilterDescriptors = [ new FilterDescriptor{ Member = "IsActive", Operator = FilterOperator.IsEqualTo, Value = true, MemberType = typeof(bool) }, new FilterDescriptor{ Member = "ParticipantId", Operator = FilterOperator.IsNullOrEmpty, Value = null, MemberType = typeof(int) } ] } };


1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 14 Aug 2024, 01:39 PM

Hello John,

There are a few things to fix in the code:

  1. There must be a separate CompositeFilterDescriptor for each column.
  2. IsNullOrEmpty is not a valid operator for int?. Use IsNull instead.
  3. It's better to use nameof() instead of hard-coded strings for the Member property.

https://blazorrepl.telerik.com/coEMbSbR38wk1Rsb34

Regards,
Dimo
Progress Telerik

Do you have a stake in the designеr-developer collaboration process? If so, take our survey to share your perspective and become part of this global research. You’ll be among the first to know once the results are out.
-> Start The State of Designer-Developer Collaboration Survey 2024

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