RadGridView filter list empty when using OData + QueryableCollectionView/IQueryable

1 Answer 19 Views
GridView
Wizard6650
Top achievements
Rank 1
Iron
Iron
Wizard6650 asked on 20 May 2024, 08:03 AM

RadGridView when source is RadDataPager + IQueryable/QueryableCollectionView:

RadGridView when source is RadDataPager + QueryableDataServiceCollectionView:

Why is the filter list empty when using IQueryable/QueryableCollectionView and how to fix this? Sample attached.

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 21 May 2024, 01:59 PM

Hello,

I tested the setup with the QueryableCollectionView collection when loading distinct values on one of the columns of RadGridView and it directly asks the service to return the distinct values, for example, for the Name property of the Customer class (since this column will be filtered). Since the OData service does not have such logic, it results in an exception raised by LINQ (used internally to make queries), which causes the distinct values to not appear in the FilteringControl.

With this being said, one approach would be to manually set the distinct values for each column. To do so, you could handle the DistinctValuesLoading event, retrieve the distinct values for the filtered column, and set it to the ItemsSource property of the event arguments.

Alternatively, the suggestions from the following StackOverflow article could be of help to you if distinct values logic should be supported in your service:

c# - Applying Distinct to OData query - Stack Overflow

Another approach would be to utilize the QueryableDataServiceCollectionView<TEntity> collection.

I hope the provided information will be of help to you.

Regards,
Stenly
Progress Telerik

A brand new ThemeBuilder course was just added to the Virtual Classroom. The training course was designed to help you get started with ThemeBuilder for styling Telerik and Kendo UI components for your applications. You can check it out at https://learn.telerik.com
Wizard6650
Top achievements
Rank 1
Iron
Iron
commented on 21 May 2024, 02:15 PM

Hi Stenly

Thank you for the response.

Handling DistinctValuesLoading for individual columns when the number of columns is substantial would be tedious.

As you noted, the distinct values do work when using a QueryableDataServiceCollectionView<TEntity>. However, in our case, TEntity is a ComplexType DTO and, for mysterious reasons, QueryableDataServiceCollectionView doesn't seem to work with ComplexTypes. It complains about missing keys presumably because it tries to internally create a DataServiceCollection without explicitly setting the TrackingMode to TrackingMode.None. QueryableDataServiceCollectionView should ideally expose an alternate constructor that allows us to explicitly set the TrackingMode.

Tags
GridView
Asked by
Wizard6650
Top achievements
Rank 1
Iron
Iron
Answers by
Stenly
Telerik team
Share this question
or