Completed
Last Updated: 25 Jul 2019 14:47 by ADMIN
Release R3 2019 (LIB 2019.2.729)
Tim
Created on: 15 May 2019 17:29
Category: UI for WinForms
Type: Bug Report
1
CompositeFilterDescriptor fails on RadGridView.FilterDescriptors.Add()

https://docs.telerik.com/devtools/winforms/controls/gridview/filtering/setting-filters-programmatically-(composite-descriptors)

When creating a composite filter descriptor with a value that contains an array of enums, it generates an expression with IN, and an exception is thrown when adding it to the FilterDescriptors on a RadGridView control.

 

Exception Message:

{"The expression contains undefined function call In()."}

 

The expression value is: ([RandomPropertyName] IN (1,3,9) OR [RandomPropertyName] = 10)

 

We have recently upgraded from 2015.2.728.40 (where this worked) to the Feb. 2019 version, then today upgraded to the May 2019 version. The issue remains.

 

The project includes the following Telerik references:

 

Telerik.WinControls

Telerik.WinControls.GridView

Telerik.WinControls.PdfViewer

Telerik.WinControls.RadDock

Telerik.WinControls.RadMarkupEditor

Telerik.WinControls.UI

Telerik.Windows.Documents.Core

Telerik.Windows.Documents.Fixed

Telerik.Windows.Zip

TelerikCommon

 

3 comments
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 17 May 2019 06:59
Hello, Tim,     

The provided code snippet was very useful for replicating the error. This is the code that fails on my end with the latest version:

this.radGridView1.EnableFiltering = true;
 
FilterDescriptor filterDescriptor = new FilterDescriptor();
filterDescriptor.Value = new string[] { "Sales Representative", "Owner", "Sales Agent" };
filterDescriptor.Operator = FilterOperator.IsContainedIn;
filterDescriptor.PropertyName = "ContactTitle";
filterDescriptor.IsFilterEditor = true;
 
CompositeFilterDescriptor cfd = new CompositeFilterDescriptor();
cfd.LogicalOperator = FilterLogicalOperator.Or;
cfd.FilterDescriptors.Add(filterDescriptor);
cfd.IsFilterEditor = true;
 
this.radGridView1.FilterDescriptors.Add(cfd);

Indeed, this behavior used to work and was broken in version 2016.1.112.

I have logged it in our feedback portal by making this thread public. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

I have also updated your Telerik points.

Currently, the possible solution that I can suggest is to add a separate FilterDescriptor  for each value in the list:

CompositeFilterDescriptor cfd = new CompositeFilterDescriptor();
cfd.LogicalOperator = FilterLogicalOperator.Or;
cfd.IsFilterEditor = true;
 
FilterDescriptor filterDescriptor = new FilterDescriptor();
filterDescriptor.Value = "Sales Representative" ;
filterDescriptor.Operator = FilterOperator.IsEqualTo;
filterDescriptor.PropertyName = "ContactTitle";            
cfd.FilterDescriptors.Add(filterDescriptor);
 
filterDescriptor = new FilterDescriptor();
filterDescriptor.Value = "Owner" ;
filterDescriptor.Operator = FilterOperator.IsEqualTo;
filterDescriptor.PropertyName = "ContactTitle";
filterDescriptor.IsFilterEditor = true;        
cfd.FilterDescriptors.Add(filterDescriptor);
 
filterDescriptor = new FilterDescriptor();
filterDescriptor.Value = "Sales Agent" ;
filterDescriptor.Operator = FilterOperator.IsEqualTo;
filterDescriptor.PropertyName = "ContactTitle";
filterDescriptor.IsFilterEditor = true;        
cfd.FilterDescriptors.Add(filterDescriptor);
 
this.radGridView1.FilterDescriptors.Add(cfd);

 

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tim
Posted on: 16 May 2019 13:48

            filterDescriptor2.Value = new string[] { "Sales Representative", "Sales Person", "Sales Floor Rep" };
            filterDescriptor2.Operator = FilterOperator.IsContainedIn;
Modify those two lines to the above and it will error out. We are using an array of enums (which end up as integers) but it looks like the same issue for strings. It looks like the internal function you're using the IsContainedIn operator is missing.
ADMIN
Dess | Tech Support Engineer, Principal
Posted on: 16 May 2019 07:55
Hello, Tim,     

According to the provided information, it is not clear enough how exactly you are adding the CompositeFilterDescriptor. However, in order to filter a certain column by extracting only several values from it, you can use the following approach. Thus, only the Owner and Sales Representative customers will be displayed:

FilterDescriptor filterDescriptor = new FilterDescriptor();
filterDescriptor.PropertyName = "ContactTitle";
filterDescriptor.Value = "Sales Representative";
filterDescriptor.Operator = FilterOperator.IsEqualTo;
 
FilterDescriptor filterDescriptor2 = new FilterDescriptor();
filterDescriptor2.PropertyName = "ContactTitle";
filterDescriptor2.Value = "Owner";
filterDescriptor2.Operator = FilterOperator.IsEqualTo;
 
CompositeFilterDescriptor cfd = new CompositeFilterDescriptor();
cfd.LogicalOperator = FilterLogicalOperator.Or;
cfd.FilterDescriptors.Add(filterDescriptor);
 cfd.FilterDescriptors.Add(filterDescriptor2);
cfd.IsFilterEditor = true;
this.radGridView1.FilterDescriptors.Add(cfd);
this.radGridView1.MasterTemplate.ExcelFilteredColumns.Add(this.radGridView1.Columns["ContactTitle"]);




However, if you believe that the code you have on your end worked in the specified 2015.2.728.40 version, it would be greatly appreciated if you can provide a sample code snippet demonstrating how to add the filter. I have attached my sample project for your reference. Feel free to modify it in a way to reproduce the experienced issue and get back to me with it so I can investigate the precise case. Thank you in advance. 

I am looking forward to your reply. 

Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.