I'm trying to generate a report which uses data in a parent-child relationship. For any Item X, it may have any number of Sub-Items. I can set this up to work with a subreport, but then the Sub-items will only list vertically, as a subreport cannot be multi-columned.
Also, the Sub-Items are being generated from a Stored Procedure which takes as a parameter the key of the Item.
I was hoping to overcome this by including a table in the main report which used the Stored Procedure data to list the Sub-Items, but I'm not sure how to execute the stored procedure for each item in the main report. Can this be done?
Also, the Sub-Items are being generated from a Stored Procedure which takes as a parameter the key of the Item.
I was hoping to overcome this by including a table in the main report which used the Stored Procedure data to list the Sub-Items, but I'm not sure how to execute the stored procedure for each item in the main report. Can this be done?
4 Answers, 1 is accepted
0
Accepted
Hello,
You can do the following:
Greetings,
Elian
the Telerik team
You can do the following:
- Bind the report to a data-source that will give you the Items (Item 1, Item 2....) (Let's name it ReportDataSource)
- Inside the detail section you can put a List control (that will give you the sub-items)
- Right-click on the List control and select Rotate Layout - this will make the items repeat horizontally and not vertically.
- Create a new data-source that will take ItemKey as a parameter (Let's name it ListDataSource).
- The parameter of the ListDataSource can be assigned to "=Fields.ItemKey" - this is from the context of the ReportDataSource
- This way, the proper parameter value will be passed to the ListDataSource for each row in the ReportDataSource.
Elian
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
0
Paul
Top achievements
Rank 1
answered on 25 Jan 2012, 09:59 PM
Thanks for the reply! I think this is exactly what I want to do, but I'm a little unclear on point 5.
I want to set the parameters for ListDataSource to be the "=Fields.ItemKey" from the ReportDataSource, but I'm not sure where to do this. In the designer, the two datasources are not linked, so how would I get access to "=Fields.ItemKey" to set the parameter in ListDataSource?
If this is done through code-behind, would I use the NeedDataSource event on the list and not associate the list with the ListDataSource in the designer?
I want to set the parameters for ListDataSource to be the "=Fields.ItemKey" from the ReportDataSource, but I'm not sure where to do this. In the designer, the two datasources are not linked, so how would I get access to "=Fields.ItemKey" to set the parameter in ListDataSource?
If this is done through code-behind, would I use the NeedDataSource event on the list and not associate the list with the ListDataSource in the designer?
0
Hi Paul,
Here are some more details on the 5th step:
All the best,
Elian
the Telerik team
Here are some more details on the 5th step:
- You have sqlDataSource1 that is the data-source for the report and it will give you all the Items. Let's say that the Key value is named "ItemKey" - this will be the field that is the key to getting the sub-items.
- You create sqlDataSource2 that will be the data-source that gets the sub-items. When you build the query (using the sqlDataSource Wizard) you add a parameter:
SELECT
.....
FROM
......
WHERE
ItemKey = @ItemKey
--you define @ItemKey as parameter
- On the next step you will be asked to set where this @ItemKey parameter will get it's value from.
- Then you bind it to the report's context current item (see Bindings).
=ReportItem.DataObject.ItemKey
- Finish the wizard.
- Add List component and assign sqlDataSource2 as data-source for it.
Elian
the Telerik team
Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!
0
Paul
Top achievements
Rank 1
answered on 26 Jan 2012, 06:57 PM
That is exactly what I wanted. Thanks for explaining!