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

search filter

1 Answer 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Avi Avni
Top achievements
Rank 1
Avi Avni asked on 24 Jun 2010, 08:12 AM

Hi,

I'm trying to implement filter search in the grid

This is the code:

 

 

private void OnFilterByTextCommand(string parameter)
  {
   var compositeDescriptor = new CompositeFilterDescriptor
                              {
                               LogicalOperator = FilterCompositionLogicalOperator.Or
                              };
   
  
   
   foreach (GridViewColumn column in RadGrid.Columns)   
   {
    var dataColumn = column as GridViewDataColumn;
    if (column == null) continue;
    
    object obj = null;
    
    try
    {
     if (dataColumn != null)
       obj = Convert.ChangeType(parameter, dataColumn.DataType);
    }
    catch
    {
     continue;
    }
    if (obj == null) continue;

    FilterOperator op = dataColumn.DataType.IsValueType ? FilterOperator.IsEqualTo : FilterOperator.Contains;
    

    FilterDescriptor filterDescriptor = new FilterDescriptor
                                         {
                                          IsCaseSensitive = false,
               Member = dataColumn.UniqueName,
               Operator=op,
               Value=obj
                                         };
   
    compositeDescriptor.FilterDescriptors.Add(filterDescriptor);
   
   
   }
   
   RadGrid.FilterDescriptors.Add(compositeDescriptor);
     
  }


I get exception in the columns that the column type is not the same as the

Item source collection in this binding member

If I bind the column to same data type and us one of this data properties

The exception is cant cast beaten the types

Someone know this problem?

Maybe I need to change the filter method?

Best Regards

Ehud

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 28 Jun 2010, 08:18 AM
Hello Ehud Pinchas,

Please check this blog post - it provides a different approach and I believe it will help you:
Highlighting Inline Search for RadGridView for Silverlight

You can find the WPF version of the project in the blog's comments

Best wishes,
Veskoni
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Avi Avni
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or