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

Programmed bool filter not shown in UI

2 Answers 62 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Software
Top achievements
Rank 1
Veteran
Software asked on 21 Nov 2018, 10:32 AM

Hi everyone!

I use a Version 2015.1.401.40 GridView to show entries with a bool value. I want to show only entries with the bool value 'false', but keep the possibility to look at the other entries too.

So I created a Behavior for the GridView:

private RadGridView Grid
    {
      get => AssociatedObject as RadGridView;
    }
 
    protected override void OnAttached()
    {
      base.OnAttached();
      Grid.DistinctValuesLoading += Grid_DistinctValuesLoading;
      Grid.FilterOperatorsLoading += Grid_FilterOperatorsLoading;
    }
 
    private void Grid_DistinctValuesLoading(object sender, GridViewDistinctValuesLoadingEventArgs e)
    {
      e.ItemsSource = new List<bool>() { true, false };
    }
 
    private void Grid_FilterOperatorsLoading(object sender, FilterOperatorsLoadingEventArgs e)
    {
      IColumnFilterDescriptor okFilter = Grid.Columns["IsStandinSetupOK"].ColumnFilterDescriptor;
      okFilter.SuspendNotifications();
      okFilter.DistinctFilter.AddDistinctValue(false);
      okFilter.ResumeNotifications();
    }

 

And as expected only entries with the IsStandinSetupOK value 'false' are shown. But that filter is not indicated by the Icon, and the filter menu looks like there is no filter active (see screenshot). Even clicking 'Clear Filter' does nothing, to remove the filter I have to activate either the true or false filter first, THEN click 'Clear Filter'.

The GridView is filled with entries only after the filter was applied.

Any idea what I did wrong?

Best regards,

Stefan

2 Answers, 1 is accepted

Sort by
0
Software
Top achievements
Rank 1
Veteran
answered on 22 Nov 2018, 03:02 PM

So, after a day of trying all possible different things I found the solution:

Even if it made perfect sense to use a DistinctFilter on a bool value, this is not what the RadGridView does, when you click on the bool filter.

Only using a FieldFilter on a bool column will also be shown in the UI.

Hope this helps somebody some day.

Best regards,

Stefan

TotallyRadicalGridView.FilterDescriptors.SuspendNotifications();
IColumnFilterDescriptor okFilter = TotallyRadicalGridView.Columns["IsPlaceholderSetupOK"].ColumnFilterDescriptor;
okFilter.SuspendNotifications();
okFilter.FieldFilter.Filter1.Operator = Telerik.Windows.Data.FilterOperator.IsEqualTo;
okFilter.FieldFilter.Filter1.Value = false;
okFilter.ResumeNotifications();
TotallyRadicalGridView.FilterDescriptors.ResumeNotifications();
0
Martin Ivanov
Telerik team
answered on 23 Nov 2018, 08:42 AM
Hello Stefan,

Thank you for sharing your solution. I am sure that this will help someone.

Regards,
Martin Ivanov
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
Software
Top achievements
Rank 1
Veteran
Answers by
Software
Top achievements
Rank 1
Veteran
Martin Ivanov
Telerik team
Share this question
or