I've been reading Telerik's documentation and I'm not sure if this is possible: I'm being asked to add tables to a report at run time, without doing so programmatically. A query is run that fetches hierarchical data, and the report owner would like to add a new table to the report for each member of the topmost parent, so that each topmost parent has their own table, with a text box title on top of the table containing the parent's name, in the following pattern:
TopParent1
[Parent1's table]
TopParent2
[Parent2's table]
...
Does anyone know how I could go about doing that without doing so programmatically? Every example and/or bit of documentation I've seen pertains to programmatically adding tables.
I was able to answer my own question as follows:
- Create two blank reports.
- On the report chosen to use for the detail report, remove the report header and footer.
- Add data source and parameter/s to the detail report (in my case, an SQL data source) and set report data source to the data source created here.
- Add group to report with the value of groupings set to the top-most result in query bound to report. (Groupings = Fields.Parent)
- Create text box with the value set to the field for the top result (textbox1.Value = Fields.Parent) or use data explorer to drag and drop Fields.Parent into the group header.
- Create text boxes to mimic table column heads (one text box for each title of the columns) and place them into the group header with the text box containing the topmost result (or Fields.Parent).
- Drag or create text fields for the rest of the fields in the query (Fields.Child1, Fields.Child2, Fields.Child3, etc) in the detail section of the report, aligned vertically with their column header. Preview the report--it should contain a table-like structure that repeats on each top result.
- Switch to other report.
- Add same parameter/s to that report.
- Add subreport item to the detail section of that report.
- Set subreport report source to Type and report document, then select the name of the detail report (the first one created here).
- Set parameter/s for subreport to the same parameter/s used in the subreport.
Using that, I was able to essentially add a table per item in the first column of the query. The report created first serves as a wrapper for the query, and because it's being placed in the other report as a subreport item with the grouping I created, it is allowed to repeat as much as it needs to in order to display all the rows in the query.
I used the Telerik documentation for master-detail reports and report structures for this.