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

RadGridView Composite Filter not Working as Expected

2 Answers 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 19 Nov 2019, 02:11 AM

I am attempting to create a composite filter in a RadGridView.

I have a column which is a string value (ReasonTrigger) and a column which is a date column (Create Timestamp). 

If I specify a single filter (not a composite) and use a Distinct Value for the ReasonTrigger, the dropdown for that column displays all of the possible values for that column for the entire collection associated with the grid. The correct data displays which are only the rows for the alert type. See attached file - WorkingDropdown.png.

 I also need to be able to further filter by specifying a Create Timestamp which is within the last 24 hours. If I add a second individual filter (not using composite), the ReasonTrigger dropdown only shows the type that qualifies based on the ReasonTrigger and the date criteria.

If I use a composite combining the ReasonTrigger and the Create Timestamp, the same behavior occurs as the previous example. The drop down only contains the distinct value specified and the correct rows but does not show the other distinct values (which should appear but not be checked). See attached files - NotWorkingDropDown.png and NotWorkingDropDown2.png

Methods below.

 

Thank you.

Tom

 

//*************************************************************************************************************

// No composite - single distinct value filter - attached file - WorkingDropDown.png

// this works well for the AlertType (see dropdown image attached - WorkingDropdown.PNG)

  private void RefreshGridColumnsByFilterNoComposite()
        {
            Telerik.Windows.Controls.GridViewColumn countryColumn = this.radGridViewAlerts.Columns.AsQueryable<Telerik.Windows.Controls.GridViewColumn>                          ().Where(c => c.Name == "ReasonTrigger").FirstOrDefault();
            Telerik.Windows.Controls.GridView.IColumnFilterDescriptor countryFilter = countryColumn.ColumnFilterDescriptor;

            this.radGridViewAlerts.FilterDescriptors.SuspendNotifications();
            countryFilter.DistinctFilter.AddDistinctValue(AlertTypeDescription);
            this.radGridViewAlerts.FilterDescriptors.Add(countryFilter);
            this.radGridViewAlerts.FilterDescriptors.ResumeNotifications();
        }

//*****************************************************************************************

// Composite Filter - Distinct filter and date filter combined into a composite filter - attached files - NotWorkingDropdown.png and NotWorkingDropdown2.png

  private void RefreshGridColumnsByFilterComposite()
        {
            Telerik.Windows.Data.FilterDescriptor createdInLast24Hours;
            CompositeFilterDescriptor newForSpecificAlertTypeCompositeFilter;
            Telerik.Windows.Controls.GridViewColumn reasonTriggerColumn =                 this.radGridViewAlerts.Columns.AsQueryable<Telerik.Windows.Controls.GridViewColumn>().Where(c => c.Name == "ReasonTrigger").FirstOrDefault();
            Telerik.Windows.Controls.GridView.IColumnFilterDescriptor countryFilter = reasonTriggerColumn.ColumnFilterDescriptor;


            newForSpecificAlertTypeCompositeFilter = new CompositeFilterDescriptor();
            this.radGridViewAlerts.FilterDescriptors.SuspendNotifications();

            // add distinct value filter for 
            countryFilter.DistinctFilter.AddDistinctValue(AlertTypeDescription);
            newForSpecificAlertTypeCompositeFilter.FilterDescriptors.Add(countryFilter);

            // add filter for create timestamp 
            createdInLast24Hours = new Telerik.Windows.Data.FilterDescriptor("CreateTimestamp", Telerik.Windows.Data.FilterOperator.IsGreaterThan, query.GetSQLServerDatetime().AddHours(-24));
            newForSpecificAlertTypeCompositeFilter.FilterDescriptors.Add(createdInLast24Hours);

            newForSpecificAlertTypeCompositeFilter.LogicalOperator = FilterCompositionLogicalOperator.And;

            this.radGridViewAlerts.FilterDescriptors.Add(newForSpecificAlertTypeCompositeFilter);

            this.radGridViewAlerts.FilterDescriptors.ResumeNotifications();
        }

2 Answers, 1 is accepted

Sort by
0
Thomas
Top achievements
Rank 1
answered on 19 Nov 2019, 02:23 AM

I forgot to mention that if I specify only the Distinct Value filter in a composite filter, it still does not work as expected.

0
Thomas
Top achievements
Rank 1
answered on 19 Nov 2019, 03:20 AM
I was able to get it working with an example from the Telerik WPF controls examples. 
Tags
General Discussions
Asked by
Thomas
Top achievements
Rank 1
Answers by
Thomas
Top achievements
Rank 1
Share this question
or