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

More than two coded FieldFilters?

3 Answers 111 Views
GridView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 01 Feb 2013, 08:58 AM
Hi guys,

is there a possibility to add more than 2 FieldFilters to a column?

I built up a DependencyProperty named Filters, when i add a filter in my viewmodel, the filter will be set to the column:

if (e.NewValue != null && e.NewValue.GetType() == typeof(FilterDescriptorCollection))
            {
                if (((FilterDescriptorCollection)e.NewValue).Count != 0)
                {
                    GridViewColumn gridColumn = this.Columns[((FilterDescriptor)((FilterDescriptorCollection)e.NewValue)[0]).Member];
                    IColumnFilterDescriptor columnFilter = gridColumn.ColumnFilterDescriptor;
 
                    columnFilter.FieldFilter.Clear();
                    columnFilter.SuspendNotifications();
 
                    foreach (FilterDescriptor filter in ((FilterDescriptorCollection)e.NewValue))
                    {
                        if (columnFilter.FieldFilter.Filter1.Value.ToString() != filter.Value.ToString() && columnFilter.FieldFilter.Filter2.Value.ToString() != filter.ToString())
                        {
                            if (columnFilter.FieldFilter.Filter1.Value.ToString() == "")
                            {
                                columnFilter.FieldFilter.Filter1.Operator = FilterOperator.Contains;
                                columnFilter.FieldFilter.Filter1.Value = filter.Value;
                            }
                            else
                            {
                                columnFilter.FieldFilter.Filter2.Operator = FilterOperator.Contains;
                                columnFilter.FieldFilter.Filter2.Value = filter.Value;
                            }
                        }
 
                    }
                    columnFilter.ResumeNotifications();
                }
            }


is there a possibility to add more than the two filters?

The problem is, that the filtering via viewmodel and rebind data is to slow. we noticed that the filtering via column is pretty much faster.
Now we got keys in a column like AEOKS... and we have to check wether the column is containing a key ("A")

Best wishes to you

David

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 01 Feb 2013, 09:46 AM
Hello David,

 You can create custom filtering control with unlimited numbers of filters using plain FilterDescriptor instead ColumnFilterDescriptor. Please check this demo for more info about custom filtering controls. 

Kind regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
David
Top achievements
Rank 1
answered on 01 Feb 2013, 10:30 AM
Hi Vlad,

thx for quick support reply.

Now I added the filterDescriptors to gridColumn.DataControl but then i got an error that "Source type must be an enumerable type."

Any idea?
0
Dimitrina
Telerik team
answered on 05 Feb 2013, 01:45 PM
Hi David,

Do you try to filter a property that is not of type String, with the "Contains" operator? Genarally this would be a cause for the error.

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
David
Top achievements
Rank 1
Answers by
Vlad
Telerik team
David
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or