Hi,
I have been using Telerik Reporting for the past couple of years. I upgraded my applications to use Q2 2012 and as a result some of the functionality that I had in place no longer works and I can't find a working alternative.
Structure:
- Master report with 3 subreports.
- Each subreport has a chart
- I set the chart series in the Page_Load event of the ASPX page that renders the report
Problem:
This doesn't work anymore - the Items collection for the SubReport is always empty. Before upgrading to Q2 2012 this worked fine.
Code Example (I stripped out application logic that has nothing to do with the reports):
I have been using Telerik Reporting for the past couple of years. I upgraded my applications to use Q2 2012 and as a result some of the functionality that I had in place no longer works and I can't find a working alternative.
Structure:
- Master report with 3 subreports.
- Each subreport has a chart
- I set the chart series in the Page_Load event of the ASPX page that renders the report
Problem:
This doesn't work anymore - the Items collection for the SubReport is always empty. Before upgrading to Q2 2012 this worked fine.
// Get the chart from the subreport
var individualContributionsReportChart = (Telerik.Reporting.Chart)individualContributionsReport.ReportSource.Report.Items[
"labelsGroupHeader"
].Items[
"chart1"
];
Code Example (I stripped out application logic that has nothing to do with the reports):
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(IsPostBack)
{
TotalContributionsOverviewReport report =
new
TotalContributionsOverviewReport();
var individualContributionsReport = ((Telerik.Reporting.SubReport)(report.Items[
"reportFooter"
].Items[
"IndividualContributionsSubReport"
]));
GetIndividualContributionsChart(individualContributionsReport, startDate, endDate, categoryNameFilter, categoryIdFilter);
ReportViewer1.Report = report;
}
}
private
void
GetIndividualContributionsChart(Telerik.Reporting.SubReport individualContributionsReport,
DateTime startDate, DateTime endDate,
string
categoryNameFilter,
string
categoryIdFilter)
{
// Get the chart from the subreport
var individualContributionsReportChart = (Telerik.Reporting.Chart)individualContributionsReport.ReportSource.Report.Items[
"labelsGroupHeader"
].Items[
"chart1"
];
// Get the chart data
var records = PersistenceFactory.GetRecords();
var categoryGroups = records.GroupBy(r => r.CategoryName);
foreach
(var g
in
categoryGroups)
{
// Create a ChartSeries and assign its name and chart type
ChartSeries chartSeries =
new
ChartSeries();
chartSeries.Name = g.Key;
chartSeries.Type = ChartSeriesType.Line;
// add new items to the series,
// passing a value and a label string
foreach
(var c
in
g)
{
ChartSeriesItem item =
new
ChartSeriesItem()
{
XValue = c.ContributionDate.ToOADate(),
YValue = Convert.ToDouble(c.Amount)
};
chartSeries.Items.Insert(chartSeries.Items.Count, item);
}
// add the series to the Chart Series collection
individualContributionsReportChart.Series.Add(chartSeries);
// format the chart axis
FormatChartAxis(individualContributionsReportChart, startDate, endDate, step);
}
}