CompositeFilterExpression not filtering as expected

1 posts, 0 answers
  1. Priyam
    Priyam avatar
    6 posts
    Member since:
    Dec 2012

    Posted 16 Jan 2014 Link to this post

    I have a grid which has to be filtered programatically based on user entry. More than one column has to be filtered and each column may have more than 1 value to be filtered upon. Like say, Col1, Col2, Col7, Col8 has to be filtered on {1,4}, {1,38}, {78,65} & {1,0} respectively.

    I have written the below code for this but looks like it filters only on the last set of values i.e. 4,38,65,0.

    public static void SetGridFilterComposite(RadGridView gridView, Dictionary<string, List<int>> filterValues)
            {
                CompositeFilterDescriptor mainDescriptor = new CompositeFilterDescriptor();
                List<int> values = null;
     
                if (filterValues == null || filterValues.Count == 0) return;
     
                ClearGridFilterColumns(gridView);
     
                foreach (string column in filterValues.Keys)
                {
                    CompositeFilterDescriptor columnDescriptor = new CompositeFilterDescriptor();
                    if (gridView.Columns.Contains(column))
                    {
                        values = filterValues[column];
                        FilterDescriptor filterDescriptor = new FilterDescriptor();
                        foreach (int value in values)
                        {
                            filterDescriptor.PropertyName = column;
                            filterDescriptor.Operator = FilterOperator.IsEqualTo;
                            filterDescriptor.Value = value;                       
                            columnDescriptor.FilterDescriptors.Add(filterDescriptor);
                        }
                        columnDescriptor.LogicalOperator = FilterLogicalOperator.Or;
                        mainDescriptor.FilterDescriptors.Add(columnDescriptor);
                    }
                }
                mainDescriptor.LogicalOperator = FilterLogicalOperator.And;
                mainDescriptor.IsFilterEditor = true;
                gridView.FilterDescriptors.Add(mainDescriptor);
            }
Back to Top