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

Issue with binding to dynamically created generic collection

1 Answer 40 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Fabrice
Top achievements
Rank 1
Fabrice asked on 24 Sep 2015, 10:18 AM

I'm having some trouble binding to a dynamically created generic collection, I don't get the expanding icon for any rows, even though I double and triple checked the bindings, but my setup is a bit complex. This behavior happens when I'm creating the columns manually (GridViewDataColumn), when I use autogenerated columns the behavior is a bit different, but still not working.

The type of the collection is:

MyDataSourceGeneric<ElementType> : 
     IQueryable<ElementType>, IQueryable, IEnumerable, IEnumerable<ElementType>,
     IOrderedQueryable<ElementType>, IOrderedQueryable​


where ElementType will be a type generated at runtime which inherits a MyRecordBase, so instances of this collection are created by:

Type recordType =  /*... generate type that inherits MyRecordBase ....  */ ;
var genericDs = typeof(MyDataSourceGeneric<>);
var dsType = genericDs.MakeGenericType(recordType);
var queriable = (IQueryable)Activator.CreateInstance( /*​.....*/ );

And this queriable is used as datasource of the TreeListView.

I experimented with 4 approaches to expose the Children, implemented as a property in the generated recordType: coerce to object, coerce to IEnumerable, coerce to IEnumerable<ElementType> and return a plain MyDataSourceGeneric<ElementType>; due to the fact that the ElementType is generated at runtime, the typed-collection properties need to be generated at runtime also.

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 29 Sep 2015, 08:23 AM
Hi Fabrice,

With the provided information I might be only guessing what the root of the issue can be. Would it be possible for you to share more details on your project setup? Have you defined the ChildTableDefinitions of the control, as demonstrated in our documentation?

Additionally, you may find the RadTreeListView online examples useful.

Best Regards,
Stefan
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
TreeListView
Asked by
Fabrice
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or