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

Clear "FieldFilter" value in column filter description

3 Answers 93 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Beata
Top achievements
Rank 1
Beata asked on 30 Apr 2018, 11:29 AM

Hi,

How can clear the "FieldFilter" value?

I have set FilteringMode="FilterRow" on my grid.

 

Until now I tried:

foreach (var column in gridWithFilters.Columns)
{
    column.ClearFilters();
    column.ColumnFilterDescriptor.Clear();
  column.ColumnFilterDescriptor.FieldFilter.Clear();
}

but this clear the filter, but not its value!

 

I have also tried:

foreach (var column in gridWithFilters.Columns)
{
    IColumnFilterDescriptor countryFilter = column.ColumnFilterDescriptor;
    countryFilter.SuspendNotifications();
    column.ColumnFilterDescriptor.FieldFilter.Filter1.Value = "";
    column.ColumnFilterDescriptor.FieldFilter.Filter1.Operator = FilterOperator.Contains;
    countryFilter.ResumeNotifications();
}

but I get an error: "Input string was not in a correct format."

 

Is it possible to clear the "FieldFilter" value?

 

Thanks!

Beata

 

3 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 03 May 2018, 10:29 AM
Hello Beata,

Thank you for the provided code. 

May I ask you some additional questions in order to better assist you? Can you specify what you mean by clearing the "FieldFilter" value? 

I tested the first approach on my side and the column filters are correctly cleared. I am attaching the sample project that I used for your reference. May I ask you to take a look at it and let me know if you are doing something different on your side? If you can specify what is the result you are expecting and potentially provide a sample picture, I will be able to better understand the described scenario.

I am looking forward to your reply.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Beata
Top achievements
Rank 1
answered on 03 May 2018, 05:25 PM

Hi Vladimir,

Thank you for the sample project, it helped me to solve my problem!

Your project has got the same issue which mine has..

The problem is when an user enters the search text, chooses "Clear Filters" operator and click "Click Filters" button... then *.Clear() and *.ClearFilters() do not clear the search text (column.ColumnFilterDescriptor.FieldFilter.Filter1.Value).

 

In order to clear the search text when "Clear Filter" operator is selected I have to programatically set the operator (for example FilterOperator.Contains).

 

Thanks,

Beata

 

0
Vladimir Stoyanov
Telerik team
answered on 08 May 2018, 11:54 AM
Hello Beata,

I am glad to hear that you managed to find a solution that works for you. Thank you for sharing it with the community.

Regards,
Vladimir Stoyanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Beata
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Beata
Top achievements
Rank 1
Share this question
or