(RadGridView + Popup Filter Control) Hide the additional fielfilter

1 Answer 73 Views
GridView
Matthieu
Top achievements
Rank 1
Matthieu asked on 14 Jun 2023, 12:44 PM

Hi team,

I am looking for a simply way to hide / remove the additional Fieldfilter in the Filter Control (Popup) of a RadGridView. Is it possible to do this whithout creating a custom column or a complete custom control ?

I just to keep the distinct filter and the first FieldFilter

Thank you, have a nice day.

Regards

Matthieu

1 Answer, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 16 Jun 2023, 11:22 AM

Hellо Matthieu,

RadGridView provides API that allows hiding the field filters, but this will hide both fields. This is done through the ShowFieldFilters property of the GridView columns.

There is no property to hide only one of the fields, but you can achieve this requirement with the following code-behind.

static MainWindow()
{
	EventManager.RegisterClassHandler(typeof(FilteringControl), FilteringControl.LoadedEvent, new RoutedEventHandler(OnFilteringControlLoaded));
}

private static void OnFilteringControlLoaded(object sender, RoutedEventArgs e)
{
	var filteringControl = (FilteringControl)sender;
	var comboBoxes = filteringControl.ChildrenOfType<RadComboBox>();
	
	var logicalOperatorComboBox = comboBoxes.FirstOrDefault(x => x.Name == "PART_LogicalOperatorsComboBox");
	if (logicalOperatorComboBox != null)
	{
		logicalOperatorComboBox.Visibility = Visibility.Collapsed;
	}

	var filter2ComboBox = comboBoxes.FirstOrDefault(x => x.Name == "PART_Filter2ComboBox");
	if (filter2ComboBox != null)
	{
		filter2ComboBox.Visibility = Visibility.Collapsed;
	}

	var filter2Editor = filteringControl.ChildrenOfType<ContentControl>().FirstOrDefault(x => x.Name == "PART_Filter2ContentControl");
	if (filter2Editor != null)
	{
		filter2Editor.Visibility = Visibility.Collapsed;
	}
}

I hope that helps.

Regards,
Martin Ivanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Matthieu
Top achievements
Rank 1
commented on 19 Jun 2023, 09:53 AM

Wouhaou ! That's perfect, exactly what I was looking for. I would not be able to do that on my own.

Thank you,

Best regards

Matthieu

Tags
GridView
Asked by
Matthieu
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or