Add subreports programmatically on the Report Footer

2 posts, 0 answers
  1. Luis
    Luis avatar
    6 posts
    Member since:
    Dec 2014

    Posted 09 Jan 2015 Link to this post

    I'm trying to add 2 sub reports programmatically on the report footer section like this

                   //This is called twice with a different myString content which is a XML string
                    XmlReaderSettings settings = new XmlReaderSettings();
                    settings.IgnoreWhitespace = true;

                    using (XmlReader xmlReader = XmlReader.Create(new StringReader(myString), settings))
                    {
                        ReportXmlSerializer xmlSerializer = new ReportXmlSerializer();

                        Telerik.Reporting.Report subreport = (Telerik.Reporting.Report)xmlSerializer.Deserialize(xmlReader);
                        Telerik.Reporting.InstanceReportSource source = new Telerik.Reporting.InstanceReportSource();
                        source.ReportDocument = subreport;

                        Telerik.Reporting.SubReport footerSubReport = new Telerik.Reporting.SubReport();
                        footerSubReport.ReportSource = source;
                        footerSection.Items.Add(footerSubReport);
                    }
                }
            }

    These 2 sub reports were created originally on the Telerik Designer with extension trdx and then changed to xml. The width of both is 15cm while on the main report, the width is 19.51cm. Enough to avoid and spread of the width.

    When only 1 sub report is added everything is ok but then when I add both subreports; blank pages are added. I tried to change the background color to identify the problem. Each sub report is really narrow (15 cm) in contrast to the main report (19.51 cm) but the report footer looks bigger in width producing the blank pages.

    I set property KeepTogether of my report footer to false and each sub report xml has the property PageBreak = Before.

    These are my two subreports in xml format

    ---------------------------------
    Sub Report 1 
    ---------------------------------

    <?xml version="1.0" encoding="utf-8"?>
    <Report Width="15cm" Name="SubReport1" xmlns="http://schemas.telerik.com/reporting/2012/3.5">
      <Items>
        <DetailSection PageBreak="Before" Height="1.7322834332784in" Name="detailSection1">
          <Style Visible="True" BackgroundColor="0, 128, 255" VerticalAlign="Bottom" />
          <Items>
            <TextBox Width="11.7999992370605cm" Height="2.3600001335144cm" Left="0.00010012308478013cm" Top="0.299999848604206cm" Value="Testing1" Name="textBox1">
              <Style>
                <Font Bold="True" />
              </Style>
            </TextBox>
          </Items>
        </DetailSection>
      </Items>
      <StyleSheet>
        <StyleRule>
          <Style>
            <Padding Left="2pt" Right="2pt" />
          </Style>
          <Selectors>
            <TypeSelector Type="TextItemBase" />
            <TypeSelector Type="HtmlTextBox" />
          </Selectors>
        </StyleRule>
      </StyleSheet>
      <PageSettings>
        <PageSettings PaperKind="Letter" Landscape="False">
          <Margins>
            <MarginsU Left="0cm" Right="0cm" Top="0cm" Bottom="0cm" />
          </Margins>
        </PageSettings>
      </PageSettings>
    </Report>

    ---------------------------------
    Sub Report 2 
    ---------------------------------

    <?xml version="1.0" encoding="utf-8"?>
    <Report Width="15cm" Name="SubReport2" xmlns="http://schemas.telerik.com/reporting/2012/3.5">
      <Items>
        <DetailSection PageBreak="Before" Height="1.7322834332784in" Name="detailSection1">
          <Style Visible="True" BackgroundColor="0, 128, 255" VerticalAlign="Bottom" />
          <Items>
            <TextBox Width="11.7999992370605cm" Height="2.3600001335144cm" Left="0.00010012308478013cm" Top="0.299999848604206cm" Value="Testing2" Name="textBox1">
              <Style>
                <Font Bold="True" />
              </Style>
            </TextBox>
          </Items>
        </DetailSection>
      </Items>
      <StyleSheet>
        <StyleRule>
          <Style>
            <Padding Left="2pt" Right="2pt" />
          </Style>
          <Selectors>
            <TypeSelector Type="TextItemBase" />
            <TypeSelector Type="HtmlTextBox" />
          </Selectors>
        </StyleRule>
      </StyleSheet>
      <PageSettings>
        <PageSettings PaperKind="Letter" Landscape="False">
          <Margins>
            <MarginsU Left="0cm" Right="0cm" Top="0cm" Bottom="0cm" />
          </Margins>
        </PageSettings>
      </PageSettings>
    </Report>

  2. Luis
    Luis avatar
    6 posts
    Member since:
    Dec 2014

    Posted 12 Jan 2015 Link to this post

    Ok. My Problem was solved by setting the location and size

    http://www.telerik.com/forums/multiple-subreports-problem
  3. DevCraft banner
Back to Top