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

Using ExpandoObject as an ObjectDataSource with the standalone designer

5 Answers 164 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 04 Oct 2017, 07:28 PM

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

Sort by
0
Todor
Telerik team
answered on 05 Oct 2017, 01:09 PM
Hi Kevin,

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;
        }
    }
}
In the above example Class1 would be the Business Object, and GetNames() would be the data source member. The property SomeName could be accessed as Fields.SomeName from the Standalone Designer.

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
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
Tursunkhuja
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 12 Jun 2019, 05:56 AM

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.

0
Todor
Telerik team
answered on 14 Jun 2019, 10:51 AM
Hello Tursunhuja,

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
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
Tursunkhuja
Top achievements
Rank 2
Iron
Iron
Veteran
answered on 14 Jun 2019, 11:10 AM

 

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?

 

0
Todor
Telerik team
answered on 19 Jun 2019, 10:12 AM
Hello Tursunhuja,

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
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
Report Designer (standalone)
Asked by
Kevin
Top achievements
Rank 1
Answers by
Todor
Telerik team
Tursunkhuja
Top achievements
Rank 2
Iron
Iron
Veteran
Share this question
or