More than two coded FieldFilters?

4 posts, 0 answers
  1. David
    David avatar
    23 posts
    Member since:
    Jan 2012

    Posted 01 Feb 2013 Link to this post

    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
  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 01 Feb 2013 Link to this post

    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.

  3. David
    David avatar
    23 posts
    Member since:
    Jan 2012

    Posted 01 Feb 2013 Link to this post

    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?
  4. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 05 Feb 2013 Link to this post

    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.

Back to Top