This is a migrated thread and some comments may be shown as answers.

Add subreports programmatically on the Report Footer

1 Answer 194 Views
Report Designer (standalone)
This is a migrated thread and some comments may be shown as answers.
Luis
Top achievements
Rank 1
Luis asked on 09 Jan 2015, 05:52 PM
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>

1 Answer, 1 is accepted

Sort by
0
Luis
Top achievements
Rank 1
answered on 12 Jan 2015, 03:31 PM
Ok. My Problem was solved by setting the location and size

http://www.telerik.com/forums/multiple-subreports-problem
Tags
Report Designer (standalone)
Asked by
Luis
Top achievements
Rank 1
Answers by
Luis
Top achievements
Rank 1
Share this question
or