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

Use FilterPopUp with ShowColumnHeaders=false

2 Answers 23 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ahmad
Top achievements
Rank 1
Ahmad asked on 13 Nov 2019, 12:15 PM

Hi,

how can I use the FilterPopUp if I set ShowColumnHeaders="false"?

I have a seperate filter icon which call this code behind:

MyGridView.ChildrenOfType<FilteringDropDown>().First().IsDropDownOpen = true;

 

With ShowColumnHeaders="true" I can open the FilterPopUp by clicking my icon or the build in filter icon. If I set ShowColumnHeaders="false" I'll get a System.InvalidOperationException: 'Sequence contains no elements' exception.

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 18 Nov 2019, 09:32 AM

Hello Kevin,

This ticket seems to be a duplicate of another one you already post. We have already answered to your questions in the other thread.

Regards,
Dinko
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
Dinko | Tech Support Engineer
Telerik team
answered on 19 Nov 2019, 10:40 AM

Hello Kevin,

I am sharing the solution here, as the community can take advantage of it.

To get the FilteringDropDown controls inside the header cells, we can subscribe to the Loaded event of the RadGridView. Inside the event handler, we can get the desired elements using the ChildrenOfType<T>() wrapped inside a Dispatcher.

It turns out that in some cases when the column headers are hidden (ShowColumnHeaders="False"), the FilteringDropDown controls inside the header cells are not loaded. Therefore the ChildrenOfType<T>() returns no sequences. To workaround this behavior we can hide the column headers after our custom logic. The following code snippet demonstrate this.

private void PlaceholdersGridView_Loaded(object sender, RoutedEventArgs e)
{
    Dispatcher.BeginInvoke((Action)(() =>
    {
        if (this.PlaceholdersGridView.ChildrenOfType<FilteringDropDown>().Count() > 0)
        {
            FirstFilteringDropDown = this.PlaceholdersGridView.ChildrenOfType<FilteringDropDown>().First();
            this.PlaceholdersGridView.ShowColumnHeaders = false;
        }
    }), DispatcherPriority.ApplicationIdle);
}

Regards,
Dinko
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.
Tags
GridView
Asked by
Ahmad
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or