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

Filtering via Ria Services using Default-Filter

2 Answers 134 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dominik
Top achievements
Rank 1
Dominik asked on 30 Mar 2011, 04:42 PM
Hi

We are using the latest RadGridView in a Silverlight 4 Ria services environment, to filter various values. For most columns we use the default filter.

We have now encountered a problem with the default string filter. To reproduce the issue one has to apply the following steps:
1. open a string filter by clicking on the column header
2. Choose "Is contained in", set a value and click filter
3. remove the entered value and click filter again.
The following error message appears:
Load operation failed for query 'GetAnforderungSet'. No applicable Method 'Contains' exists in type 'Object'
-> at System.Linq.Dynamic.ExpressionParser.ParseMemberAccess(Type type, Expression instance)
   at System.Linq.Dynamic.ExpressionParser.ParsePrimary()
   at System.Linq.Dynamic.ExpressionParser.ParseUnary()
   at System.Linq.Dynamic.ExpressionParser.ParseMultiplicative()
   at System.Linq.Dynamic.ExpressionParser.ParseAdditive()
   at System.Linq.Dynamic.ExpressionParser.ParseComparison()
   at System.Linq.Dynamic.ExpressionParser.ParseLogicalAnd()

Possibly, the "Is Contained in" functionality does not work properly with the entity framework we use. Anyway, I have to get rid of the error. Therefore, I have the following questions:

- How can i influence the options that are displayd in the string filter? I would like to remove the critical options entirely (The are not that easy to grasp for the normal user anyway). I tried the FieldFilterEditorCreated event but this seems not to work. The FilterControl of the column is always empty. I don't want to write the entire filter control just because of one thing.
- What else can I do get rid of that error.

My prefered solution would be to remove the options "Is contain in" and "Is not contained in" from the dropdown.

Thanks in advance for your help and greetings.


PS: I think your controls are great. The only thing i would wish is that a few more methods and properties were protected instead of private.

2 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 31 Mar 2011, 09:12 AM
Hello Dominik,

You are right. The Contains and IsContainedIn cannot be handled by the QueryProvider.

I believe that this forum post will help you modify the available filter operators. Basically you can create a custom filtering control and tweak the two operator combos. Something like this:

public class CustomizedFilteringControl : FilteringControl
    {
  
        public override void Prepare(GridViewBoundColumnBase column)
        {
  
            base.Prepare(column);
  
            var availableOperators = new List<FilterOperator>()
            {
                FilterOperator.IsEqualTo,
                FilterOperator.IsNotEqualTo
            };
  
            var cbo1 = this.ChildrenOfType<RadComboBox>()
            .Where(b => b.Name == "PART_Filter1ComboBox")
            .FirstOrDefault();
            cbo1.ItemsSource = availableOperators;
  
            var cbo2 = this.ChildrenOfType<RadComboBox>()
            .Where(b => b.Name == "PART_Filter2ComboBox")
            .FirstOrDefault();
            cbo2.ItemsSource = availableOperators;
        }
  
    }

The rest is explained in the forum post. There are sample projects attached there.

Let me know if there are problems.

Best wishes,
Ross
the Telerik team
0
Dominik
Top achievements
Rank 1
answered on 31 Mar 2011, 04:00 PM
Hi
thanks for your answer.
I think the correct link is:
http://www.telerik.com/community/forums/wpf/gridview/hide-and-filtering-options.aspx
Tags
GridView
Asked by
Dominik
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Dominik
Top achievements
Rank 1
Share this question
or