Issue with binding to dynamically created generic collection

2 posts, 1 answers
  1. Fabrice
    Fabrice avatar
    22 posts
    Member since:
    Jan 2015

    Posted 24 Sep 2015 Link to this post

    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.

  2. Answer
    Stefan avatar
    771 posts

    Posted 29 Sep 2015 Link to this post

    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,
    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
Back to Top