I have a subreport that has it's fields generated dynamically. The fields are set to dock left and their width is calculated by taking the panel that houses them and dividing it's width by the number of fields. This works out nicely and I have n-number of same width textboxes in the panel once the report is rendered.
Now, I'd like the ability to add this subreport to any report and have it resize itself correctly. The problem I'm running into is that even though in the master report I may have sized the subreport to 3 inches, it still is calculating it's width based on how it designed in it's own designer. In other words, I'd like to dynamically calculate the width based on how it's defined in the parent.
Is this possible?
Now, I'd like the ability to add this subreport to any report and have it resize itself correctly. The problem I'm running into is that even though in the master report I may have sized the subreport to 3 inches, it still is calculating it's width based on how it designed in it's own designer. In other words, I'd like to dynamically calculate the width based on how it's defined in the parent.
Is this possible?
4 Answers, 1 is accepted
0
Hi Gary,
When rendered, the subreport item is always sized to the dimensions of the report it nests. You don't need to know the exact size of the inner report. There is no way to force the inner report to size to the bounds of the subreport item.
Of course you know how big is your inner report you can always resize the corresponding subreport item with a custom code.
Anyway we would like to know why do you need to resize the subreport item in the report definition and in what export format (HTML, PDF, etc.).
Kind regards,
Svetoslav
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
When rendered, the subreport item is always sized to the dimensions of the report it nests. You don't need to know the exact size of the inner report. There is no way to force the inner report to size to the bounds of the subreport item.
Of course you know how big is your inner report you can always resize the corresponding subreport item with a custom code.
Anyway we would like to know why do you need to resize the subreport item in the report definition and in what export format (HTML, PDF, etc.).
Kind regards,
Svetoslav
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Gary
Top achievements
Rank 1
answered on 18 Aug 2008, 01:53 PM
I'm resizing the the fields in the subreport item because until runtime I don't know how many I will have. The subreport is basically building a matrix on the fly, without knowledge of how many columns it will have. I need the subreport to able to be included in any parent report and with whatever size the parent report decides to make it and it should resize the columns contained within it autmatically. All columns need to be the same width.
If the parent report sizes the subreport to be small it might look like this:
-------------------------------------
| Never | Sometimes | Often |
-------------------------------------
Group 1 | 0 | 3 | 2 |
-------------------------------------
Group 2 | 1 | 2 | 3 |
-------------------------------------
If it sizes it to be bigger it needs to stretch proportionately like this:
---------------------------------------------------------
| Never | Sometimes | Often |
---------------------------------------------------------
Group 1 | 0 | 3 | 2 |
---------------------------------------------------------
Group 2 | 1 | 2 | 3 |
---------------------------------------------------------
Again, the columns are created at runtime since there is no way to determine how many they will be... If there is a better solution to this problem please let me know as I've just started using the Reporting framework.
Thanks!
If the parent report sizes the subreport to be small it might look like this:
-------------------------------------
| Never | Sometimes | Often |
-------------------------------------
Group 1 | 0 | 3 | 2 |
-------------------------------------
Group 2 | 1 | 2 | 3 |
-------------------------------------
If it sizes it to be bigger it needs to stretch proportionately like this:
---------------------------------------------------------
| Never | Sometimes | Often |
---------------------------------------------------------
Group 1 | 0 | 3 | 2 |
---------------------------------------------------------
Group 2 | 1 | 2 | 3 |
---------------------------------------------------------
Again, the columns are created at runtime since there is no way to determine how many they will be... If there is a better solution to this problem please let me know as I've just started using the Reporting framework.
Thanks!
0
Accepted
Hi Gary,
As I understand from your explanation, the missing part of your custom layout is the size of the SubReport item from the master report. In order to obtain this before calculating the column widths you can use report parameters.
private void Details_NeedDataSource(object sender, EventArgs e)
{
Telerik.Reporting.Processing.Report report = sender as Telerik.Reporting.Processing.Report;
Telerik.Reporting.Processing.SubReport subReportItem = report.Report.Items.Find("subReport1", true)[0] as Telerik.Reporting.Processing.SubReport;
// Now you can use subReportItem.Size to accomplish your goal
...
}
I hope this will help you to make the sub-report to resize automatically depending of the main-report SubReport item size.
All the best,
Hrisi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
As I understand from your explanation, the missing part of your custom layout is the size of the SubReport item from the master report. In order to obtain this before calculating the column widths you can use report parameters.
- In the main report in the SubReport.Parameters add parameter with value set to the width of the SubReport item.
- in the sub-report define the report parameter with the same name
- In your custom layout algorithm use the value from this parameter
private void Details_NeedDataSource(object sender, EventArgs e)
{
Telerik.Reporting.Processing.Report report = sender as Telerik.Reporting.Processing.Report;
Telerik.Reporting.Processing.SubReport subReportItem = report.Report.Items.Find("subReport1", true)[0] as Telerik.Reporting.Processing.SubReport;
// Now you can use subReportItem.Size to accomplish your goal
...
}
I hope this will help you to make the sub-report to resize automatically depending of the main-report SubReport item size.
All the best,
Hrisi
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Gary
Top achievements
Rank 1
answered on 21 Aug 2008, 01:01 AM
Thanks Hrisi! This is exactly what I was looking for!