Clear all filters programmatically

3 posts, 0 answers
  1. Gerard
    Gerard avatar
    16 posts
    Member since:
    Mar 2016

    Posted 26 Oct Link to this post

    Hi,

    Press Clear All button and do: 

    DatagridResults.FilterDescriptors.SuspendNotifications();
    foreach (var col in DatagridResults.Columns)
    {
        if (col.ColumnFilterDescriptor.IsActive)
        {
            col.ClearFilters();
        }
    }
    DatagridResults.FilterDescriptors.ResumeNotifications();

     

    Filter icon is still black (indicating we are still filtering). Note that this actually shows a false information to the user, because the Filter has been removed, but it is not reflected.

    Only occurs with columns I load default filters (which had saved). To load the saved filters:

    public IColumnFilterDescriptor LoadColumnFilter(IColumnFilterDescriptor columnFilterDescriptor)
    {
        if (FilterSettings != null && FilterSettings.Count > 0)
        {
            foreach (FilterSetting setting in FilterSettings)
            {
                if (setting.ColumnUniqueName.Equals(columnFilterDescriptor.Column.UniqueName))
                {
                    if (setting.Filter1 != null)
                    {
                        columnFilterDescriptor.FieldFilter.Filter1.Operator = setting.Filter1.Operator;
                        columnFilterDescriptor.FieldFilter.Filter1.Value = setting.Filter1.Value;
                        columnFilterDescriptor.FieldFilter.Filter1.IsCaseSensitive = setting.Filter1.IsCaseSensitive;
                    }
     
                    columnFilterDescriptor.FieldFilter.LogicalOperator = setting.FieldFilterLogicalOperator;
     
                    if (setting.Filter2 != null)
                    {
                        columnFilterDescriptor.FieldFilter.Filter2.Operator = setting.Filter2.Operator;
                        columnFilterDescriptor.FieldFilter.Filter2.Value = setting.Filter2.Value;
                        columnFilterDescriptor.FieldFilter.Filter2.IsCaseSensitive = setting.Filter2.IsCaseSensitive;
                    }                
                    return columnFilterDescriptor;
                }
            }
         }
         return columnFilterDescriptor;
    }

     

    As I have to remove a load default filter to the filter icon actualize correctly?

    Thanks, Gerard.

     

     

     

     

     

    As I have to remove a loaded default filter to the filter icon actualize correctly?
    As I have to remove a loaded default filter to the filter icon actualize correctly?
    As I have to remove a loaded default filter to the filter icon actualize correctly?
    As I have to remove a loaded default filter to the filter icon actualize correctly?
  2. Gerard
    Gerard avatar
    16 posts
    Member since:
    Mar 2016

    Posted 26 Oct in reply to Gerard Link to this post

    Solved! The event is called loading filters twice at the start.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Lance | Tech Support Engineer, Sr.
    Admin
    Lance | Tech Support Engineer, Sr. avatar
    138 posts

    Posted 26 Oct Link to this post

    Hello Gerard,

    I'm happy to see that you've resolved the matter, I'll mark this thread as resolved.

    For your convenience and for future reference, here's the documentation relating to your inquiry:

    - Programmatic filtering (this contains examples on how to clear the filters, for both a single column and multiple column)

    Please let us know if you have any further questions. Thank you for contacting Support and for choosing Telerik by Progress.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Telerik by Progress
    Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Back to Top