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

QueryableCollectionView item type

3 Answers 243 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Olle
Top achievements
Rank 1
Olle asked on 15 Jan 2018, 09:57 AM

When using QueryableCollectionView, it takes an IEnumerable as source. Are there any further requirements on the type of the individual items?

My input data is an object-array, and in the code I'm currently investigating a DataTable is created and its DefaultView is used as input to the QueryableCollectionView. I was wondering if I could just skip the DataTable and just use a List<object[]> instead. Apparenty not, but I'm curious as to why?

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 15 Jan 2018, 05:16 PM
Hi,

QueryableCollectionView is a jack-of-all-trades interface that helps binding an IEnumerable instance to RadGridView. It takes care of three things in particular: ensuring IQueryable support (which is required by RdaGridView's sorting, filtering, grouping, which are implemented with LINQ expressions); Ensuring I(Editable)CollectionviewSupport and providing a list of properties for the item type. The described scenarios will vary in behavior when extracting item properties is concerned. If you use a simple IEnumerable, the logic that resolves ItemProperties will get the first item and resolve its type, then it will use TypeDescriptor.GetProperties() to fetch the list. On the other hand, if a DataTable.Default view is passed, DataTable.Columns will be iterated through, returning an instance of a DataFieldPropertyDescriptor for each column. List<object[]> will not provide a meaningfull set of properties, as QCV will handle it as an IEnumerable of a CLR type invoking TypeDescriptors.GetProperties for typeof(object[]).

Regards,
Ivan Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Olle
Top achievements
Rank 1
answered on 16 Jan 2018, 12:05 PM
That makes sense. I guess I thought that the ItemProperties wasn't required since I already specify Columns for the RadGridView. But if using AutoGenerateColumns it obviously wouldn't work. Thanks for your answer!
0
Ivan Ivanov
Telerik team
answered on 16 Jan 2018, 04:40 PM
Hi,

Indeed, when columns are specified explicitly, item properties will not be used for columns creation. However, they will be needed to make the default filtering, grouping, sorting logic work. RadGridView's data engine uses the meta data for a certain member (property) to build a Linq expression. Alas, DataMemberBinding does no contain the whole information that is needed, so item properties will still be needed in some scenarios. Can you please what is the goal that you are after? Maybe you can use an implementation of DynamicObject, if you need to generate dynamic data source at run-time?

Regards,
Ivan Ivanov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Olle
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Olle
Top achievements
Rank 1
Share this question
or