Declined
Last Updated: 10 Apr 2015 07:46 by ADMIN
ADMIN
Plamen
Created on: 20 Feb 2013 08:59
Category: GridView
Type: Bug Report
1
FIX. RadGridView - cannot set the default FilterDescriptor from Contains to IsEqual operator to a TextBoxColumn
Steps to reproduce:
1) Add RadGridView control
2) Add GridViewTextBoxColumn
2) Enable filtering: 

            this.radGridView1.EnableFiltering = true;

3) Programmatically set filter descriptor:

            FilterDescriptor filter = new FilterDescriptor();
            filter.PropertyName = "TextBoxColumn";
            filter.Operator = FilterOperator.IsEqualTo;
            filter.IsFilterEditor = true;
            
            this.radGridView1.FilterDescriptors.Add(filter);

Expected result: the default FilterDescriptor is changed from Contains to IsEqual
Actual result: can not set the default FilterDescriptor from Contains to IsEqual operator to a TextBoxColumn

Workaround:

        private void OnFilterExpressionChanged(object sender, FilterExpressionChangedEventArgs e)
        {
            GridViewTemplate owner = sender as GridViewTemplate;
            List<string> filterExpressions = new List<string>();

            for (int i = 0; i < owner.FilterDescriptors.Count; i++)
            {
                FilterDescriptor descriptor = owner.FilterDescriptors[i];
                string expression = null;

                CompositeFilterDescriptor compositeFilterDescriptor = descriptor as CompositeFilterDescriptor;

                if (compositeFilterDescriptor != null)
                {
                    foreach (FilterDescriptor filterDescriptor in compositeFilterDescriptor.FilterDescriptors)
                    {
                        if (string.IsNullOrEmpty(filterDescriptor.PropertyName) ||
                            owner.Columns[filterDescriptor.PropertyName] == null)
                        {
                            continue;
                        }
                    }

                    expression = CompositeFilterDescriptor.GetCompositeExpression(compositeFilterDescriptor);
                }
                else
                {
                    if (string.IsNullOrEmpty(descriptor.PropertyName) ||
                        owner.Columns[descriptor.PropertyName] == null)
                    {
                        continue;
                    }

                    if (descriptor.Value == null && (descriptor.Operator == FilterOperator.IsNotEqualTo || descriptor.Operator == FilterOperator.IsEqualTo))
                    {
                        expression = string.Empty;
                    }
                    else
                    {
                        expression = descriptor.Expression;
                    }
                }

                if (!string.IsNullOrEmpty(expression))
                {
                    filterExpressions.Add(expression);
                }
            }

            string logicalOperator = (owner.FilterDescriptors.LogicalOperator == FilterLogicalOperator.And) ? " AND " : " OR ";
            string resultExpression = String.Join(logicalOperator, filterExpressions.ToArray());
            e.FilterExpression = resultExpression;
        }
1 comment
ADMIN
Ralitsa
Posted on: 10 Apr 2015 07:46
Unable to reproduce such case with the specified versions. The behavior works as expected in the latest version as well.