After installing release 2022.2.511, the distinct filters of our grid views stopped working. We are using popup filters in a custom class with both distinct checkboxes and field filters visible. Clicking on any distinct checkbox and then clicking Apply Filter button would always filter the grid, but after the 2022.2.511 release, clicking on distinct checkboxes and clicking Apply Filter now does nothing but close the filter popup with no effect to the results. However, if the EnableDistinctValuesFiltering property is set to true, and some text is typed in the distinct search text box, and then the checkbox is checked and Apply Filter is clicked, the filtering works.
Is there some breaking change that was made that we should know about when dealing with distinct filters in the custom popup? Is there any settings that we can try to help resolve this issue?
Thanks, Bob
4 Answers, 1 is accepted
Hello Bob,
I have contacted our developers' team regarding this behavior and we will consider it as a bug. As a result of this, a logged bug report regarding this matter can be found in our feedback portal. The public item could be found at the following link:
In addition, for bringing this to our attention, you could find your Telerik points updated.
With this said, I hope the provided information will be of help to you.
Regards,
Stenly
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.
Hello Bob,
We had an exception that was occurring in regards to the FilteringControl element that is used in the RadGridView that was present in the 2022.2.511 version of our assemblies. It was fixed in the 2022.2.523 LIB version and the fix is also present in the 2022 R2 SP1 (the version for the service pack is 2022.2.621).
With this being said, would it be possible to the application that this behavior is present in with the 2022.2.621 version and see whether this is still present? If it, would it be possible to try and isolate this behavior in a sample project so that I could test it on my end and provide further information based on it?
Regards,
Stenly
Progress Telerik
Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.
Hello Stenly,
I upgraded the version to 2022.2.621 and the issue is still there. I noticed that if EnableDistinctValuesFiltering is enabled, and if any text is typed into the distinct search, even if the text is then cleared the filtering on the distinct values will work. It is only on the initial load of distinct values that selecting any of them does not work.
It may be difficult to replicate how we use the filtering control in a sample application because we are using asynchronous server calls to load the distinct values, and we custom load the grid data one page at a time as needed. When loading the distinct values, we override the DistinctValuesLoading event:
theGrid.DistinctValuesLoading += delDistinctValuesLoading = new EventHandler<GridViewDistinctValuesLoadingEventArgs>(GridHelper.HandleDistinctColumnValues);
The GridHelper.HandleDistinctColumnValues method will then call an asynchronous service to retrieve the distinct values for any data. The return of this asynchronous call will then modify the collection. Here is the code we are using to initiate the asynch call and handle the collection change:
RadObservableCollection<object> cloneCollection;
public void HandleDistinctColumnValues(object sender, GridViewDistinctValuesLoadingEventArgs e)
{
Assert.IsNotNull(_gridDataGetAllDistinctColumnValues); // Delegate must be set for distinct column values
if (e == null)
throw new ArgumentNullException("GridViewDistinctValuesLoadingEventArgs");
// Distinct Load as background operation to improve performance
var column = (e.Column as DataBoundColumn);
var dataType = column?.DataType;
cloneCollection = new RadObservableCollection<object>();
if (column?.ShowEmptyValueDistinctFilter == true)
if (dataType == typeof(string))
cloneCollection.Insert(0, string.Empty);
else
cloneCollection.Insert(0, FilterDescriptor.UnsetValue);
e.ItemsSource = cloneCollection;
var worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_LoadDistinctValues);
worker.RunWorkerAsync(e);
}
private void worker_LoadDistinctValues(object sender, DoWorkEventArgs e)
{
RadObservableCollection<object> collection = new RadObservableCollection<object>();
collection.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(collection_CollectionChanged);
GridViewDistinctValuesLoadingEventArgs args = (GridViewDistinctValuesLoadingEventArgs)e.Argument;
if ((args.Column as DataBoundColumn).ShowDistinctFilters)
{
_gridDataGetAllDistinctColumnValues(args.Column.UniqueName, collection);
}
}
void collection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
bool bWorkDone = false;
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
RadObservableCollection<object> originalColl = sender as RadObservableCollection<object>;
if (originalColl.Count > 0)
{
foreach (object o in sender as RadObservableCollection<object>)
{
if (!cloneCollection.Contains(o))
cloneCollection.Add(o);
}
}
bWorkDone = true;
});
while (!bWorkDone)
Thread.Sleep(10);
Since I know that changing the search value in any way will allow the distinct filtering to work, I am going to try to programmatically modify the search value and then clear it to see if that can be used as a workaround. Hopefully the insight into our code may help you figure out why this no longer works the same.
Thanks,
Bob
I have determined that modifying the distinct collection on any type of delay is causing this issue. Here is some sample code that will cause the distinct filters to not work for the filters that are added on the delay. The first two filters will work, the second two will not. This was working before the latest releases.
RadObservableCollection<object> distinctFilterCollection;
theGrid.DistinctValuesLoading += delDistinctValuesLoading = new EventHandler<GridViewDistinctValuesLoadingEventArgs>(HandleDistinctColumnValues);
public void HandleDistinctColumnValues(object sender, GridViewDistinctValuesLoadingEventArgs e)
{
distinctFilterCollection= new RadObservableCollection<object>();
distinctFilterCollection.Add("Distinct Filter 1");
distinctFilterCollection.Add("Distinct Filter 2");
e.ItemsSource = distinctFilterCollection;
var worker = new BackgroundWorker();
worker.DoWork += new DoWorkEventHandler(worker_LoadDistinctValues);
worker.RunWorkerAsync(e);
}
private void worker_LoadDistinctValues(object sender, DoWorkEventArgs e)
{
Thread.Sleep(1000); // Make sure there is some kind of delay to trigger the issue
DispatcherHelper.CheckBeginInvokeOnUI(() =>
{
distinctFilterCollection.Add("Distinct Filter 3");
distinctFilterCollection.Add("Distinct Filter 4");
});
}
The reported behavior by Bob has been fixed with the 2022.3.1109 version of our assemblies.
With this in mind, may I ask if you could share a bit more information about this behavior? For example, are there any reproduction steps that I could follow? Additionally, is this reproducible in a sample project?
Hi Stenly,
I developed a Grid View by loading the Distinct Filters from DB for all the columns.
Till 2021 Telerik release it was all working fine. Now I upgraded to 2023.3.1114 and distinct filters worked well on first time filters screen loading. If I open again and check/uncheck distinct values then filter button do not respond. It do not detect any changes in Distinct filters unless I do changes in Filter text boxes.
Hello Oksana,
The reason behind this behavior came from an update to the FilteringControl element's default control template. This update was so that the distinct values filtering functionality could be supported. This change produced the unwanted behavior when using a version of the assemblies that supported the distinct values filtering functionality, but had an outdated version of the control template of the FilteringControl element.
With this in mind, we have an article that pinpoints the reason in the default control template of the FilteringControl element and how to update it, so that filters are correctly applied/removed:
Filters Work Only the First Time in RadGridView - Telerik UI for WPF
I hope the provided information will be of help to you.
Thanks for the support. The solution worked for my case and issue resolved.
Thanks