Dynamic properties in object data source

3 posts, 1 answers
  1. Rick
    Rick avatar
    2 posts
    Member since:
    Nov 2016

    Posted 28 May Link to this post

    Hello,

     

    We're currently working on an application which supports dynamic properties, created by the users of our application. We want these properties to be available to our users when they're designing a report with the standalone report designer.

    In our codebase (c#) a class with dynamic property support looks like:

    [DataObject]
    public class Employee {
       public string Id { get; set; }
       public string Name{ get; set; }
       public List<DynamicProperty> DynamicProperties { get; set; }
    }
     
    public class DynamicProperty {
       public string Name { get; set; }
       public object Value { get; set; }
    }

     

    Let's say one of our users created 2 dynamic properties for Employee:

    1. Title
    2. Adres

    When we load Employee into the report designer as object data source, it displays:

    • Id
    • Name
    • DynamicProperties

    But what we would actually like to see is:

    • Id
    • Name
    • Title
    • Adres

     

    We thought of a couple solutions for our problem:

    • Use web service data source so we can generate json, based on the dynamic properties. We don't actually want to use a web service for this.
    • Runtime compile a new class with the flattened properties and use this as object data source. Seems like a lot of effort for what seems to be a small problem.

     

    Since we don't actually want to use any of these solutions I was wondering if there is an easier way to deal with this problem. 

     

    Thanks in advance!

     

    Kind regards,

    Rick Brants

  2. Answer
    Todor
    Admin
    Todor avatar
    171 posts

    Posted 31 May Link to this post

    Hi Rick,

    If I understood correctly, one of the properties of the data source is a collection of DynamicProperty class that has itself two properties - Name and Value. The requirement is the user to see design time in the Standalone designer the property with the value of its Name property, i.e. if DynamicProperties.Name is "Title" the property to be visible as Fields.Title.

    The above cannot be directly achieved.
    However, by assigning the DynamicProperties collection as DataSource of a nested data item (i.e. List, Table, etc) its inner properties will be visible as Fields.Name/Value inside the data item. It is not possible to show the property as Fields.Title (the value of the property Name). 
    This is due to the fact that the report engine, hence the report designers, use System.Reflection to resolve ObjectDataSources, and only property names are available runtime.

    Regards,
    Todor
    Progress 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
  3. Rick
    Rick avatar
    2 posts
    Member since:
    Nov 2016

    Posted 31 May in reply to Todor Link to this post

    Thank you for the clarification! 
Back to Top