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

Best practice to include non-datasource data on report

3 Answers 56 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Iron
Iron
Chris asked on 28 Sep 2011, 06:50 PM
What is the best way to get a large amount of dynamic, non-data source data into a report.

For example, on an invoice the header contains contact details for the company and vendor.  If these details are not in the data source, what's the best way to pass it into the report?  

For example, here's how I run a report now.

This  report uses a DataObject class as it's data source, with a method that returns a List for the actual data source.  

var r = new ProfitSystemReports.SalesByCategory();
r.ReportParameters["startDate"].Value = Model.StartDate;
r.ReportParameters["endDate"].Value = Model.EndDate;
ReportViewer1.Report = r;

In this case, the parameters are used to filter the report.  Should one use a bunch of parameters to hold the extra data?  Or, create user-defined functions that return the needed values?  What if the DataObject class also had public properties, could they be accessed from the report?

In this case, I'm using Reporting 5.1, with ASP.NET 3.5 and MVC 3 with the web viewer.

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 29 Sep 2011, 03:02 PM
Hi Chris,

Report Parameters are not meant to be used for this purpose - sending data to the report engine. The major usages of the report parameters are:
  • to vary report data retrieved from a Data Source component
  • in expressions to directly provide a value
  • in data item filtering, sorting or grouping criteria
A valid solution would be to use a SubReport item, as long as you're not using it in page sections. Another approach would be to create a base report with the header company info and inherit all reports from it. See Generic Report, but Customized forum thread for more info.

Regards,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Chris
Top achievements
Rank 1
Iron
Iron
answered on 29 Sep 2011, 04:18 PM
Ok, I understand that parameters are not intended to be used to pass non-datasource data items into a report.  What would the recommended procedure be?

Put another way, if you are creating the base report with the header company info to inherit all reports from it, and the header company info (name, address, contact details, terms, etc.) do not come from the data source, but they are dynamic and not known at design-time, how would you get that data into the report?
0
Steve
Telerik team
answered on 04 Oct 2011, 03:47 PM
Hi Chris,

There is some misunderstanding from previous post. "I understand that parameters are not intended to be used to pass non-datasource data items" - not true, point #2 (in expressions to directly provide a value) means that you can pass any value. If your report parameter is databound it would show value from its data source, if not it would show unbound value you set to it.
Since you now state that the header is always dynamic, the suggestion to create a base class does not seem like a good idea.
You can still use SubReport (if not in page sections), expose public properties or utilize the report parameters as a last resort.
Either solution would work, I just wanted to note that the general purpose of the report parameters is not for such cases, since you're asking for "best practice".

Greetings,
Steve
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Iron
Iron
Answers by
Steve
Telerik team
Chris
Top achievements
Rank 1
Iron
Iron
Share this question
or