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

Generating Report Dynamically or multiple line detail?

1 Answer 100 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
gureumi
Top achievements
Rank 1
gureumi asked on 14 Sep 2009, 03:44 PM
Hi,

I wonder if it is possible to generate report for a LINQ object that might  have different number of fields.
For example, we currently have 7 active stores and have to make a sales/stock report as follows.
Each data row requires two lines to fit in the letter-sized printed output.
------------------------------------------------------------------
 Item       Store1        Store2      Store3      Store4
         Sale Stock   Sale Stock Sale Stock Sale Stock
             Store5          Store6    Store7        Total
         Sale Stock   Sale Stock Sale Stock Sale Stock
------------------------------------------------------------------

But a few month later we are going to open 2 more stores so there will have to be 3 line for each item.
The header should look like the following.
------------------------------------------------------------------
 Item       Store1        Store2      Store3      Store4
         Sale Stock   Sale Stock Sale Stock Sale Stock
             Store5          Store6    Store7        Store8
         Sale Stock   Sale Stock Sale Stock Sale Stock
             Store9                                            Total
         Sale Stock                                      Sale Stock
-----------------------------------------------------------------

In case of .NET ReportViewer Object, I heard that we can modify the RDLC file at run time and generate the report dynamically.

Olso is there any way to allow detail-line of each data-row to be extended into multiple lines dynamically??

Thanks,

------------------------------------------------------------------

1 Answer, 1 is accepted

Sort by
0
Milen
Telerik team
answered on 16 Sep 2009, 10:24 AM
Hello gureumi,

When the supplied report data source has variable column count, you do not have other option than to dynamically (programmatically) generate the report definition. Of course not the whole report, but the items that should represent the changing columns.

The idea is to loop through the available columns and to add a TextBox (or other appropriate) item(s) to the needed section with appropriate Size and Location, so that you achieve the desired layout.

Here you may find examples of pseudo code, but the easiest way to find an example is to design the needed layout in the report designer and then review the generated MyReport.designer.cs(vb) source code file.

As to the Height of the section with dynamic items: Set the Height of the section to some small value, and while the report is rendered it will grow automatically to accommodate the items you added.

Another idea is (if possible) to change the structure of the supplied data source to not have variable column count, but to represent the different stores in the rows of the data source:
Instead of for example datasource like:

Date              Store1     Store2   Store3
--------------------------------------------------
2009.09.15  $1000$   $2000   $3000
2009.09.16  $1001$   $2001   $3001


to have one like:
Date              Store     Value
--------------------------------------------------
2009.09.15  Store1  $1000$
2009.09.15  Store2  $2000$
2009.09.15  Store3  $3000$
2009.09.16  Store1  $1001$
2009.09.16  Store2  $2001$
2009.09.16  Store3  $3001$


Such a data source does not have dynamic columns and most important is suitable for a Crosstab item, which can generate the columns for you. The only difference will be that it cannot "wrap" the column creation, it generates table.

Hope this information helps.

Kind regards,
Milen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
General Discussions
Asked by
gureumi
Top achievements
Rank 1
Answers by
Milen
Telerik team
Share this question
or