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

Clear all filters programmatically

5 Answers 444 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Gerard
Top achievements
Rank 1
Gerard asked on 26 Oct 2016, 11:02 AM

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?

5 Answers, 1 is accepted

Sort by
0
Gerard
Top achievements
Rank 1
answered on 26 Oct 2016, 03:02 PM
Solved! The event is called loading filters twice at the start.
0
Lance | Manager Technical Support
Telerik team
answered on 26 Oct 2016, 04:34 PM
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!
0
Lou
Top achievements
Rank 1
answered on 19 Feb 2019, 09:49 AM

Hi Lance

Unfortunately the problem Gerard posted ist not solved. If I clear my filters with

DatagridResults.FilterDescriptors.SuspendNotifications();

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

The filter icons are 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.

Can you explain how I can clear the black icons indicating filtering where as it is in fact not.

Thanks.

Regards,

Lou

 

 

 

0
Lance | Manager Technical Support
Telerik team
answered on 19 Feb 2019, 04:27 PM
Hi Lou,

I have created a Priority Ticket on your behalf so that we can continue the investigation there. You should have received an email by now, please click the ticket's link to open and reply to the thread (if you do not see an email, you can see your tickets list here My Support Tickets).

I will reply to that ticket soon with a demo you can use to compare against. If you have any further trouble afterward, we can investigate your implementation in more detail.

Regards,
Lance | Technical Support Engineer, Principal
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Lou
Top achievements
Rank 1
answered on 20 Feb 2019, 11:01 AM

Thanks, Lance, for quick reply. The following code from the sample project you sent me is working fine now: 

                gridView.FilterDescriptors.SuspendNotifications();
                foreach (var column in gridView.Columns)
                {
                    column.ClearFilters();
                }
                gridView.FilterDescriptors.ResumeNotifications();

Best regards,

Lou

 

 

Tags
GridView
Asked by
Gerard
Top achievements
Rank 1
Answers by
Gerard
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Lou
Top achievements
Rank 1
Share this question
or