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

Report from generic list?

5 Answers 442 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lars
Top achievements
Rank 1
Lars asked on 04 Dec 2012, 07:19 PM
Before calling my report, I generate a generic list of business objects. The processing is quite complex and I do not want to try to use Telerik's parameter facility to do this. 

How can I pass this List<BusinessObject> to Telerik Reporting at runtime? What do I use as a datasource in order to design the report?

I am using VS2010 and Report Q1 2011.

(Sorry I mis-posted this issue in the Winforms area - could not move it)

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 06 Dec 2012, 09:46 AM
Hi Lars,

For backwards compatibility reasons Telerik Reporting supports binding directly to IEnumberable/IListSource objects (incl. arrays, collections, DataSet, DataTable, DataView, DbDataAdapter), so you can bind directly to your List. However instead you might consider using the ObjectDataSource that can handle this types of data sources.

As for the design time support, check out the following help article: Working With Data at Design Time.

Greetings,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Lars
Top achievements
Rank 1
answered on 06 Dec 2012, 08:39 PM
I've read "Working with Data at Design Time", specifically in relation to binding at runtime. I do not understand the following statement:

In this case you would have to mock your data just to enable the Report Designer to show any data schema.

I have passed an generic IEnumerable to my report and assigned it to the report's datasource property. But there are errors on the report: "The expression contains object 'ItemNumber' that is not defined in the current context." ItemNumber is a property within the class contained in the IEnumerable. I defined the value of one of the report's textboxes as "=Fields.ItemNumber" but there must be something else to do to bind the fields to the report.
0
Steve
Telerik team
answered on 11 Dec 2012, 02:41 PM
Hi Lars,

We cannot get any schema out of generic IEnumerable as it is a generic object. We use reflection to find the property used in the expression, when at run time, but we cannot do anything for schema at design time/preview. So you can either make the IEnumerable of a specified type or as described in the help article, create an object with public properties which we can use to get the schema and use it as DataSource only for the sake of the design time.

Kind regards,
Steve
the Telerik team

HAPPY WITH TELERIK REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

0
Tamas
Top achievements
Rank 1
answered on 24 May 2013, 06:47 AM
Hi Steve,

I have a similar problem.  I want to bind a datatable to my report in needdatasource event. But in report designer I have no datasource so I don't have any dataschema. So I cannot create the report layout in designer.

You wrote this :

"create an object with public properties which we can use to get the schema and use it as DataSource only for the sake of the design time."

I try to find more information about this in help, but I didn't find anything.

A little example would be great.
Thx.
0
Stef
Telerik team
answered on 28 May 2013, 07:32 AM
Hello Tamas,

Here is the answer from the other threads you have opened:

We retrieve the data schema automatically based on the datasource type. Thus if in the report designer (data explorer and expression editor) fields list is empty we will appreciate if you elaborate on your data layer (CreateData() method). 

Generally you can try to debug Visual Studio design time - while you are using the Visual Studio report designer you have to open another Visual Studio instance, select Debug->Attach to process to debug another instance of devenv.exe and select Debug->Exception... to enable  the First Chance Exceptions.


Regards,
Stef
Telerik

Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.

Tags
General Discussions
Asked by
Lars
Top achievements
Rank 1
Answers by
Steve
Telerik team
Lars
Top achievements
Rank 1
Tamas
Top achievements
Rank 1
Stef
Telerik team
Share this question
or