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

Show Filter value to other control

3 Answers 219 Views
GridView
This is a migrated thread and some comments may be shown as answers.
gerardo
Top achievements
Rank 1
Veteran
gerardo asked on 10 Sep 2020, 05:59 AM

Good day,

Is there a way I can access the filter value used in the GridView and Show it to other part of my page? Just like the SelectionBox of RadMultiColumnComboBox with the column and operation used?

Thank you.

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 14 Sep 2020, 11:32 AM

Hello Gerardo,

What comes up to my mind is to subscribe to the Filtering event of the RadGridView. Inside the event handler, you can get the filter descriptors collection and get the filtered value. 

private void GridView_Filtering(object sender, Telerik.Windows.Controls.GridView.GridViewFilteringEventArgs e)
{
    var filterDescriptors = e.Added as List<IFilterDescriptor>;
    var fiterValue = (filterDescriptors[0] as FilterDescriptor).Value;
}

The Value property above of the FilterDescriptor will be the value of the first TextBox inside the filter popup window. I hope this approach will work for you.

Regards,
Dinko
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive , special prizes and more, for FREE?! Register now for DevReach 2.0(20).

0
gerardo
Top achievements
Rank 1
Veteran
answered on 27 Sep 2020, 07:48 AM

Good day Sir Dinko. I got the Idea from your code.

I noticed that filterDescriptors provides the filter value and the selected operation that I needed. But it gives the actual column name of the grid and not the assigned Header text value. Is is possible to have the Header text of the column where I filtered?

 

Also, Since I have the filtered value, Is it possible to clear/remove the filter value outside the GridView?

The idea is to have the list of Filtered Value I got from filterDescriptors and have the ability to remove specific filter from the list that will automatically apply to the GridView.

 

Thank you.

0
Dinko | Tech Support Engineer
Telerik team
answered on 30 Sep 2020, 03:01 PM

Hi Gerardo,

To get the Header property of the column, you can use the ColumnFilterDescriptor property from the event arguments.

private void gridview_Filtering(object sender, Telerik.Windows.Controls.GridView.GridViewFilteringEventArgs e)
{
    var filterDescriptors = e.Added as List<IFilterDescriptor>;           
    var columnHeader = e.ColumnFilterDescriptor.Column.Header;
    var fiterValue = (filterDescriptors[0] as FilterDescriptor).Value;    
}

What I can suggest for the second approach is to use the FilterDescriptors collection of the RadGridView. You can get every value from the collection and list them in a separate control. Then if the user removes a filter, you can remove it from the FilterDescriptors collection. You could check the Programmatic Filtering help article, which I think will get in handy in a case if you want to filter the control programmatically.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
GridView
Asked by
gerardo
Top achievements
Rank 1
Veteran
Answers by
Dinko | Tech Support Engineer
Telerik team
gerardo
Top achievements
Rank 1
Veteran
Share this question
or