3 Answers, 1 is accepted
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).
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.
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/.