Subreports are displayed in the wrong order

5 posts, 0 answers
  1. Dave Hayward
    Dave Hayward avatar
    40 posts
    Member since:
    Jul 2012

    Posted 23 Feb 2010 Link to this post

    I have a master report that uses a single group. Within each group, I display a subreport with data for the group. When the report is displayed using the ReportViewer control on my web page, the first sub-report is empty, and the second sub-report contains the data for first group etc.

    I step through the code in the debugger to be sure the correct data is being supplied for the group data, and it appears to be correct.

    Are there any known problems with using grouping and sub-reports? Are there any other mistakes on my part that could cause this behaviour?

    It's happeneing on two separate master/sub-report pairs, and it's very repeatable.

    TIA.
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 24 Feb 2010 Link to this post

    Hello Dave Hayward,

    You have not provided any details about whether that subreport is independent or it shows filtered data based on a parameter from the master report. If this is the case and you're passing the parameter value programmatically, make sure that you're working with the processing report objects and not with the definition ones. You can find more info in the following help article: Understanding Events.

    Regards,
    Steve
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. DevCraft banner
  4. Dave Hayward
    Dave Hayward avatar
    40 posts
    Member since:
    Jul 2012

    Posted 25 Feb 2010 Link to this post

    Steve,

    Thanks for your reply. The sub-report shows filtered data based on a parameter passed to it from the master report. I used a project pasted on the web site as a guide (it's called 124347 but I don't know the link). In any case I'm applying the same procedure to my report as the one in the example. I now wonder how the sample works given the link on Understanding Events as the parameter is passed to the definition report rather than the processing report object.

    In 124347:

            private void detail_ItemDataBinding(object sender, System.EventArgs e)  
            {  
                Telerik.Reporting.Processing.ReportSection section =  
                    sender as Telerik.Reporting.Processing.ReportSection;  
                if (null != section)  
                {  
                    System.Data.DataRowView dataRow = section.DataItem as System.Data.DataRowView;  
                    if (null != dataRow)  
                    {  
                        this.reportTeamCrew1.ManagerID = (int)(dataRow["EmployeeID"]);  
                    }  
                }  
            }  
     

    In my report I use:

            private void detail_ItemDataBinding(object sender, EventArgs e)  
            {  
                Telerik.Reporting.Processing.ReportSection section = sender as Telerik.Reporting.Processing.ReportSection;  
                if (null != section)  
                {  
                    SubmissionList dataRow = (SubmissionList)(section.DataObject.RawData);  
                    if (null != dataRow)  
                    {  
                        agonistSubmittedReport1.ExamId = dataRow.ExamId;  
                        agonistSubmittedReport1.CaseId = dataRow.CaseId;  
                        agonistSubmittedReport1.ShowReport();  
                    }  
                }  
            }  
     

    According to the 'Understanding Events' document, this shouldn't work (or it should produce peculiar results) for the reasons stated in the document.

    I tried to figure out how to reference the processing object subreport and cast it to my class so I could pass the parameters, but can't quite figure out how to do that. Do you have any hints on how to do that?

    TIA
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 26 Feb 2010 Link to this post

    Hi Dave Hayward,

    There is some misunderstanding - I was talking about report parameters and clearly you're using custom properties for this purpose. Can you clarify what agonistSubmittedReport1 is? If this is the definition subreport and ExamId is a custom property, the correct syntax would be:

    agonistSubmittedReport1.ReportSource.ExamId = dataRow.ExamId;

    If still having problems, put a break point in the event and debug what is the value when the report is initially rendered and what is the value on refresh and you would pinpoint where the problem lies.

    Generally speaking, the correct approach would be using the NeedDataSource event of the subreport for this purpose - this approach loads only the necessary data from the database server by executing parameterized SQL queries in the NeedDataSource event.
    The other possible approach is by using report filters and parameters - this approach populates all data from the database server on the client machine and filters the records of the detail report according to each record of the master report using report filters and report parameters. You can see this in action in our Invoice demo report.

    I have created a small sample project with reports that illustrates this method (see the attached ZIP archive file). You'll need the Adventure Works sample database that ships with every Telerik Reporting installation in order to run the sample report.

    Sincerely yours,
    Steve
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  6. Dave Hayward
    Dave Hayward avatar
    40 posts
    Member since:
    Jul 2012

    Posted 26 Feb 2010 Link to this post

    Steve,

    Thanks! You saved the (my) day. I used your attached project almost exactly and it solved the problem. About the only change I made (besides the actual report layout) was to change the way I prepared the data (I use LinqToSql, so I build an IList<mycalss> and use that as the data source, so when I need to retrieve the data when the sub-report needs data, my data is in

    (myclass)(subReport.DataObject.RawData) rather than in DataObject. Apart from that it works. Thanks again.

Back to Top
DevCraft banner