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

RadGridView ColumnFilterDescriptor in OR?

1 Answer 120 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Michele
Top achievements
Rank 2
Michele asked on 07 Dec 2012, 08:11 AM
Hello,
I need to programmatically filter on a string field,that has values comma separated, for example

a1,b2,c4,d5

I adds the filter asn item is added to a custom object I've created my code is

public void FilteringItemAdded(IF.UserControls.ItemAddedEventArg eventArgs)
       {
           if (radGridView == null) return;
 
           if (radGridView.Columns["Tags"] == null) return;
 
           GridViewColumn cityColumn = this.radGridView.Columns["Tags"];
 
           IColumnFilterDescriptor columnDescriptor = cityColumn.ColumnFilterDescriptor;
 
           columnDescriptor.SuspendNotifications();
           columnDescriptor.DistinctFilter.AddDistinctValue(eventArgs.ItemAdded.Name);
           columnDescriptor.ResumeNotifications();
 
           var lst = columnDescriptor.DistinctFilter.FilterDescriptors;
 
           foreach (FilterDescriptor q in lst)
           {
               q.Operator = FilterOperator.Contains; //this is since I don't know how to directly a filtrer of tpye contains
           }
       }

my problem is that if I've

item1 | a1,b2,c4
item2 |
item3 | b2

If I set first b2 I only have Item1 and Item3, when I add the tag "a1"  I don't have only item1 ... I think because the single distinct filter are matched in OR clause...is there a way of using them in AND?

Thanks
Paolo

1 Answer, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 07 Dec 2012, 08:31 AM
Hi,

I am afraid that there is no way to change the operator from OR to AND and that is by design. Distinct values are always OR'ed. You can develop your own custom ColumnFilterDescriptor that will generate the LINQ expression that you need.

I have attached a sample project which might give you ideas how to build your custom column filter descriptor. Please, examine it carrefully, since your task is somewhat similar, i.e. read what the user has entered in the UI and then based on that information -- create a filtering LINQ expression.

Kind regards,
Rossen Hristov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Michele
Top achievements
Rank 2
Answers by
Rossen Hristov
Telerik team
Share this question
or