多页时 Telerik 报告布局问题
Telerik Reporting Layout issue when multiple pages
在遗留项目中,我们使用旧版本的 telerik 报告(2013 年第 3 季度)创建 PDF 报告。我们有一个 master/subreport,其中一个子报表内容是在代码中添加的。当有足够的项目需要它在下一页呈现时,我们可以看到 page2 上的第二个项目呈现在第一个项目之上。即使我添加面板而不是我们的自定义控件,我也会得到相同的行为。使用的报告仅包含一个面板项,其中 keeptogether 设置为 true。
private void ContractualInformationChartItemDataBinding(object sender, EventArgs eventArgs)
{
panel.Items.Clear();
panel.Width = Unit.Inch(4.82);
var week = int.Parse(ReportParameters["Week"].Value.ToString());
var year = int.Parse(ReportParameters["Year"].Value.ToString());
var regionId = int.Parse(ReportParameters["RegionId"].Value.ToString());
using (var provider = new Provider())
{
var report =
new TimeReportService().GetOrCreateWeeklyReport(week, year, provider)
.WeeklyRegionReports.First(wr => wr.RegionId == regionId && wr.DeletedBy == null && wr.DeletedDate == null);
if (report.ContractualInformations != null && report.ContractualInformations.Any())
{
foreach (var rig in report.ContractualInformations.Where(r => r.DeletedBy == null && r.DeletedDate == null).Select(zt => zt.Rig).Distinct())
{
//The code for the chart can be replaced with a new panel with yellow background and the issue is still the same
var budget = new ContractualInformationService().GetContractualInformation(report.WeeklyReport.Week, report.WeeklyReport.Year, rig.Id, ContractualInformationType.Budget, provider);
var forecast = new ContractualInformationService().GetContractualInformation(report.WeeklyReport.Week, report.WeeklyReport.Year, rig.Id, ContractualInformationType.Forecast, provider);
var chart = new ContractualInformationChart(budget, forecast)
{
Docking = DockingStyle.Top,
Height = Unit.Inch(1.35),
Width = panel.Width,
};
chart.Style.Padding.Bottom = Unit.Inch(0.05);
panel.Items.Add(chart);
}
}
}
}
}
这里的问题是对接 = DockingStyle.Top。将其替换为 Location 并根据循环计数计算 y 值解决了布局问题
在遗留项目中,我们使用旧版本的 telerik 报告(2013 年第 3 季度)创建 PDF 报告。我们有一个 master/subreport,其中一个子报表内容是在代码中添加的。当有足够的项目需要它在下一页呈现时,我们可以看到 page2 上的第二个项目呈现在第一个项目之上。即使我添加面板而不是我们的自定义控件,我也会得到相同的行为。使用的报告仅包含一个面板项,其中 keeptogether 设置为 true。
private void ContractualInformationChartItemDataBinding(object sender, EventArgs eventArgs)
{
panel.Items.Clear();
panel.Width = Unit.Inch(4.82);
var week = int.Parse(ReportParameters["Week"].Value.ToString());
var year = int.Parse(ReportParameters["Year"].Value.ToString());
var regionId = int.Parse(ReportParameters["RegionId"].Value.ToString());
using (var provider = new Provider())
{
var report =
new TimeReportService().GetOrCreateWeeklyReport(week, year, provider)
.WeeklyRegionReports.First(wr => wr.RegionId == regionId && wr.DeletedBy == null && wr.DeletedDate == null);
if (report.ContractualInformations != null && report.ContractualInformations.Any())
{
foreach (var rig in report.ContractualInformations.Where(r => r.DeletedBy == null && r.DeletedDate == null).Select(zt => zt.Rig).Distinct())
{
//The code for the chart can be replaced with a new panel with yellow background and the issue is still the same
var budget = new ContractualInformationService().GetContractualInformation(report.WeeklyReport.Week, report.WeeklyReport.Year, rig.Id, ContractualInformationType.Budget, provider);
var forecast = new ContractualInformationService().GetContractualInformation(report.WeeklyReport.Week, report.WeeklyReport.Year, rig.Id, ContractualInformationType.Forecast, provider);
var chart = new ContractualInformationChart(budget, forecast)
{
Docking = DockingStyle.Top,
Height = Unit.Inch(1.35),
Width = panel.Width,
};
chart.Style.Padding.Bottom = Unit.Inch(0.05);
panel.Items.Add(chart);
}
}
}
}
}
这里的问题是对接 = DockingStyle.Top。将其替换为 Location 并根据循环计数计算 y 值解决了布局问题