Fit Subreport in Detail section

6 posts, 0 answers
  1. Nathalia
    Nathalia avatar
    3 posts
    Member since:
    Sep 2014

    Posted 21 May 2015 Link to this post

    I have a report that has two subreports aligned side by side. I need to make both subreports have the same height, preferentially, that they occupy the complete detail, until pagefooter's start, so, even if there aren't enough items in the subreport, the lines must reach the footer.
    The subreports have different tops, so I can't set the exact same height for both.
     
    To guarantee that the subreport header is shown on every page, I've inserted a subreport inside the subreport. Furthermore, I've added a panel in the detail of the subreport that has the column's header and I've inserted the nested subreport inside this panel. The panel also contains a shape component of vertical line type, because, as I have said, I wanted to make the margins of the subreport and its columns to grow on every page until they reach the footer.
     
    Attached there are two prints of the desired layout.

    Is there a simple way of doing that?
    Would you, please, send me a sample code of how this could be done?
     
    Best regards.
  2. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 22 May 2015 Link to this post

    Hello Nathalia,

    Reports are data-driven and sections/items will be rendered only for the number of records in the used data sources, where items grow only to fit properly their content - Design Considerations for Report Item Layout. Stretching an item/section to the bottom of the physical document's page is not supported.

    Instead try achieving the desired layout by using background images with the required lines in the page.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Nathalia
    Nathalia avatar
    3 posts
    Member since:
    Sep 2014

    Posted 22 May 2015 in reply to Stef Link to this post

    Hi, Stef.

    I've read the documentation that you've sent to me. 
    In my experiments, I've noticed that there isn't a way of stretching the subreport, that is why I inserted it into a panel. 

    I don't believe that defining an image backgroung is going to solve the problem, because the first page detail will always be different than the following pages.

    Right now, I'm setting the size of the panel and of the shapes, which I've spoken previously, according to the quantity of items to present in the subreport. Although, I've realized that there is a slight difference between the item's size in edition mode and in print mode. For example, I've configured the height of the items to 0,4 cm, but when is printed it seems that it occupies 0,43cm each. So the size of lines and panel are wrong when the report is printed.

    I've also tried to use KeepTogether property, but in some cases it doesn't work well because the space reserved for the subreport in the first page is smaller than the consecutive pages.

    I've wondered if there is a way to get "pageCount" parameter in report constructor. If I had this value, may be I could force the panel and lines sizes based on the detail height in print mode. How do I get this parameter by code? 

    Thanks.
    Regards.
  4. Nasko
    Admin
    Nasko avatar
    1045 posts

    Posted 26 May 2015 Link to this post

    Hello Nathalia,

    The PageCount Global Object can be passed to a User Function and used in its body. Note that due to the specifics of the Report Life Cycle, the PageCount object can only be used inside the Page Header/Footer of the report.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. Nathalia
    Nathalia avatar
    3 posts
    Member since:
    Sep 2014

    Posted 02 Jun 2015 Link to this post

    Hi, Nasko.

    I've calculated the quantity of pages of the report, but the size of the panels and shapes still growing strangely.
    As I have the final height of the detail by page, I can set the height of the components based on it. 
    To assure that I've been setting the right height for the components, I've even measured the desired space, that the subreports should occupy, after printing. But it seems that there's something been added to these height after I've set the property (I've debugged the application as a guarantee that the property was, indeed, receiving the value that I've sent).
    The routine that feeds the property is in the constructor of the report, after the call of the method InitializeComponent.

    Any idea of what could be happening to these component's height? 
    As an extra information, I've already changed the properties of all components from the report to TextWrap as false and CanGrow as false.
    Summing up, I wish that the margins around the charts named as "Vale Pedágio" and "Condutores" meet the reportfooter section in all the pages that these are presented. But, as it is possible to see in the last but one page of the attached image from the printed pdf, there's some "extra height" being added to the subreport height.
    Following, a code sample of the main calculation routine.

    private void SetSubReportsLayouts()
    {
    // Receive the total number of pages of the report
    int numberOfPages = ReturnReportNumberOfPages();
    // the report footer section is set to apply a page break before it prints, so I subtract this page
    numberOfPages = (this.reportFooterSection1.Visible) ? numberOfPages - 1 : numberOfPages;
    // here I calculate how many pages of the report has the standard detail height, so I also subtract the first page
    int numberOfPagesWithStandardHeight = numberOfPages - 1;

    // the attribute standard detail height was manually set to 14.2cm globally
    // the first page detail height from valePedagio was manually set to 10.5 cm globally
    // valesPedagio is the name of the left subreport
    double heightValePedagioDoubleType = (numberOfPagesWithStandardHeight) *
    (_standardDetailHeight - valesPedagio.ReturnHeaderHeight().Value) +
     _firstPageDetailHeightValePedagio - valesPedagio.ReturnHeaderHeight().Value; 

    Unit heightValePedagioUnitType = (new Telerik.Reporting.Drawing.Unit(heightValePedagioDoubleType, Telerik.Reporting.Drawing.UnitType.Cm));

    // the first page detail height from condutor was manually set to 12.6 cm globally
    // condutores is the name of the right subreport
    Unit heightCondutorUnitType = (new Telerik.Reporting.Drawing.Unit(numberOfPagesWithStandardHeight, Telerik.Reporting.Drawing.UnitType.Cm).
     Multiply((new Telerik.Reporting.Drawing.Unit(_standardDetailHeight, Telerik.Reporting.Drawing.UnitType.Cm).
    Subtract(condutores.ReturnHeaderHeight())).Value)).
     Add((new Telerik.Reporting.Drawing.Unit(_firstPageDetailHeightValePedagio, Telerik.Reporting.Drawing.UnitType.Cm).
      Subtract(condutores.ReturnHeaderHeight())));

    // I set the subreport panels and shapes height inside the detail through a method inside the subreport
    this.valesPedagio.SetReportDetailHeight(heightValePedagioUnitType);
    this.condutores.SetReportDetailHeight(heightCondutorUnitType);

    // After executing this routine, the heights from ValesPedagio (panel and shapes) and Condutores (panel and shape) are, respectively,
    // 49.1 cm
    // 51.2 cm
    }

    Thanks.
    Best regards, 
    Nathalia
  6. Stef
    Admin
    Stef avatar
    3610 posts

    Posted 05 Jun 2015 Link to this post

    Hi Nathalia,

    Since items are separated in their own reports combined in one via SubReport items, there is no setting to synchronize the size of items placed in separate reports. Also separate reports are not aware where the physical page ends, thus stretching the items to the bottom of the physical page is not supported.

    In your approach you are relying on custom calculations for the number of pages and the items' sizes based on the report's physical dimensions and sizes, which may work in some custom cases but will require manual adjustments on a trial-error basis. The provided code is insufficient to determine what causes the issue. It might be related to the used font and its settings (as space per character and space around it), the saved items' sizes and locations, and/or the content (data) rendered in the report.
    Details how items are positioned in the report can be found in Design Considerations for Report Item Layout.  Also it is recommended to serialize in a TRDX file the modified in code report definition to check the produced report template with the Standalone Report Designer.


    On a side note, an image in the background can mimic that the item is continuing to the end of the physical page. The image can be set as report's BackgroundImage, where items can have specified their own background color to cover the image where needed.

    Regards,
    Stef
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top