or
var reportViewerModel = reportViewer.DataContext as ReportViewerModel; if (reportViewerModel.State.Equals("ViewerPageState")) { reportViewerModel.PrintReportCommand.Execute(null); }this.DataSource = new List<Test>()
{
new Test(){Name = "hasan"},
new Test(){Name = "Ali"}
};
3rd report just contains two sub report objects in its detail section.
When I run the application I see only one of the sub reports. Can someone check the source at http://www.filedropper.com/telerikreporttest and tell me what the problem is?
If I check preview of individual report, they show the data perfectly fine but something wrong happens on runtime.
Also the behavior seems unpredictable because sometimes it shows data from both the reports but repeats the static text as many times as there are rows in the second subreport. This happens if I change the order of subreports in the detail seciton of Master report.
Thanks
/// <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