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

Dynamic properties in object data source

2 Answers 283 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Rick
Top achievements
Rank 1
Rick asked on 28 May 2018, 10:15 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Todor
Telerik team
answered on 31 May 2018, 09:23 AM
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
0
Rick
Top achievements
Rank 1
answered on 31 May 2018, 09:36 AM
Thank you for the clarification! 
Tags
Report Designer (standalone)
Asked by
Rick
Top achievements
Rank 1
Answers by
Todor
Telerik team
Rick
Top achievements
Rank 1
Share this question
or