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
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:
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
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.