Hi,
I am attempting to use the standalone report designer with an Object DataSource that returns ExpandoObject. I have been following this example to provide a custom type description provider for ExpandoObject:
http://www.telerik.com/support/kb/reporting/details/how-to-use-objectdatasource-with-expandoobject
However, I am having trouble getting this to work with the standalone designer. I cannot think of a way to get the custom type description provider registered when running in the context of the standalone designer. Is there a way to accomplish this (maybe through configuration)?
Thanks!
-Kevin
5 Answers, 1 is accepted
It would be necessary to Extend the Standalone Report Designer with the assembly containing your custom data providing functions. This assembly should be added also to the folder containing the Standalone Designer.
Note that when using objectDataSource with known properties you would be able to see the properties during design time.
In the case of ExpandoObject you would not see properties in the Standalone Designer, but they would still be accessible (Fields.PropertyName) if you know their names.
Here is an example of how the code of the data providing class could look:
using
System;
using
System.Collections;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Dynamic;
namespace
ReportLibrary1
{
public
static
class
Class1
{
static
Class1()
{
TypeDescriptor.AddProvider(
new
ExpandoObjectTypeDescriptionProvider(),
typeof
(ExpandoObject));
}
public
static
IEnumerable GetNames()
{
var results =
new
List<dynamic>();
dynamic result1 =
new
ExpandoObject();
result1.SomeName =
"name01"
;
results.Add(result1);
dynamic result2 =
new
ExpandoObject();
result2.SomeName =
"name02"
;
results.Add(result2);
dynamic result3 =
new
ExpandoObject();
result3.SomeName =
"name03"
;
results.Add(result3);
return
results;
}
}
}
Note that the ExpandoObjectType is registered in the constructor of the static data providing class Class1.
Note also that the assembly that should be added to the Standalone Designer config file should containg
- the data providing class (Class1 in the snippet)
- the classes from the article about ExpandoObjects you have referred to
- ExpandoObjectTypeDescriptionProvider
- ExpandoObjectTypeDescriptor
- ExpandoObjectPropertyDescriptor
Regards,
Todor
Progress Telerik
Hi,
I am also using the standalone report designer with an ObjectDataSource that returns ExpandoObject. The problem I have that the dynamic properties of ExpandoObject are now showing in the data explorer. I did create some new ExpandoObject objects and set property values as your example above.
Before I was using WebServiceDatasource and the properties were showing on data explorer. But, now we decided to use ObjectDataSource. So I don't have known properties, that's why I used ExpandoObject with dynamic properties. What should I do to show those dynamic properties in the Standalone Report Designer? Maybe I need to use another type of object rather than an expando object?
Thanks.
In the WebServiceDataSource our code explores the entire data to find the properties names and display them in design time. In the ExpandoObject the properties names are already set to Key and Value and these are the names to be displayed in design time. Therefore, indeed you need to use an alternative type with properties with appropriate names. A possible solution is explained in the Dynamically create property name forum post.
Check also the How can we cancel the report? forum thread where I have replied to a similar question.
Regards,
Todor
Progress Telerik
Hi Todor,
The given solution of that post is explaining to create just dynamic object using DynamicObject. So, this can be alternative instead of using ExpandoObject, but dynamic properties still not showing on design time when you use Standalone report designer. Look at the attached pictures. What is your suggestion in this case?
We recommend using business objects with properties with known names. Officially we do not support dynamic objects and cannot guarantee that the names of an ExpandoObject or Dynamic object would be resolved by the Standalone designer.
I noticed that you have logged a feature request for the same. We consider all requests from our users. You will receive a notification when the status of the request changes. The implementation of the new features depends strongly on the number of the received votes.
Regards,
Todor
Progress Telerik