Hi,
in Q2 2010 Telerik Reporting I set the DataSource of a Report to null in the constructor and created dynamically sized textfields dynamically, dependent on some ReportParameter sent by a Silverlight Application via the Telerik WCF Service, in the overridden OnNeedDataSource method.. This worked like a charm.
In Q3 2010 Telerik Reporting the constructor of the Report also gets called twice like before. Once while requesting the report initially to be previewed in the Silverlight Report Viewer, the second time if exporting the Report to PDF or any other format from the Menu of the Silverlight Report Viewer. The first time the constructor is called, OnNeedDataSource gets called correctly and the dynamic Textfields get created, the second time the constructor is called (before saving to file), OnNeedDataSource does not get called, even though the DataSource is again set to null in the constructor.
In Short: Preview shows correct Report like in Q2. Saving to PDF (or any other format) produces blank file in Q3. In Q2 the Report was being saved correctly.
Since this is a time-critical issue, I am temporarily stepping back to Q2 2010 as of now. I hope this issue can be resolved.
Some code reconstructed to visualize what I wrote in the upper paragraphs:
Constructor:
in Q2 2010 Telerik Reporting I set the DataSource of a Report to null in the constructor and created dynamically sized textfields dynamically, dependent on some ReportParameter sent by a Silverlight Application via the Telerik WCF Service, in the overridden OnNeedDataSource method.. This worked like a charm.
In Q3 2010 Telerik Reporting the constructor of the Report also gets called twice like before. Once while requesting the report initially to be previewed in the Silverlight Report Viewer, the second time if exporting the Report to PDF or any other format from the Menu of the Silverlight Report Viewer. The first time the constructor is called, OnNeedDataSource gets called correctly and the dynamic Textfields get created, the second time the constructor is called (before saving to file), OnNeedDataSource does not get called, even though the DataSource is again set to null in the constructor.
In Short: Preview shows correct Report like in Q2. Saving to PDF (or any other format) produces blank file in Q3. In Q2 the Report was being saved correctly.
Since this is a time-critical issue, I am temporarily stepping back to Q2 2010 as of now. I hope this issue can be resolved.
Some code reconstructed to visualize what I wrote in the upper paragraphs:
Constructor:
/// <summary>
/// Initializes a new instance of the <see cref = "OverviewReportBase{T}" /> class.
/// </summary>
public
OverviewReportBase()
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
// Set DataSource to null, so that the NeedDataSource Event gets fired.
// This is done because otherwise the ReportParameters are not getting filled from the Silverlight Client.
// see a comment on http://blogs.telerik.com/blogs/posts/09-12-07/programmatic_initialization_of_report_parameter_values_in_telerik_reporting_silverlight_viewer.aspx for more information
DataSource =
null
;
}
OnNeedDataSource method:
/// <summary>
/// Called when the report needs a data source.
/// </summary>
/// <param name = "sender">The sender.</param>
/// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
protected
override
void
OnNeedDataSource(Object sender, EventArgs e)
{
Unit writeableArea = CalculateWidthOfWriteableArea();
IEnumerable<String> columnNames = ((Object[]) ReportParameters[
"columnNames"
].Value).OfType<String>();
Int32 columnCount = columnNames.Count();
IEnumerable<Int32> columnPercentages =
((Object[]) ReportParameters[
"columnPercentages"
].Value).Select(x => Int32.Parse(x.ToString()));
Double summedUpWidth = 0D;
for
(Int32 i = 0; i < columnCount; i++)
{
Unit controlWidth = writeableArea.Multiply(columnPercentages.ElementAt(i)).Divide(100);
TextBox captionTextBox =
new
TextBox
{
Location =
new
PointU(
new
Unit(summedUpWidth, UnitType.Mm),
new
Unit(0, UnitType.Cm)),
Size =
new
SizeU(controlWidth,
new
Unit(0.75, UnitType.Cm)),
Name =
String.Format(CultureInfo.InvariantCulture,
"captionTextBox{0}"
, i),
StyleName =
"Caption"
,
TextWrap =
false
,
Value = RetrieveDisplayName(columnNames.ElementAt(i))
};
labelsGroupHeader.Items.Add(captionTextBox);
TextBox dataTextBox =
new
TextBox
{
Location =
new
PointU(
new
Unit(summedUpWidth, UnitType.Mm),
new
Unit(0, UnitType.Cm)),
Size =
new
SizeU(controlWidth,
new
Unit(0.75, UnitType.Cm)),
Name = String.Format(CultureInfo.InvariantCulture,
"dataTextBox{0}"
, i),
StyleName =
"Data"
,
TextWrap =
false
,
Value = RetrieveValuePathOfColumn(columnNames.ElementAt(i))
};
detail.Items.Add(dataTextBox);
summedUpWidth += controlWidth.Value;
}
SetDataSourceHere();
base
.OnNeedDataSource(sender, e);
}
Best Regards