This is a migrated thread and some comments may be shown as answers.

adressing Detailsection of subreport

2 Answers 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 23 Nov 2015, 12:12 PM

Hello

Im having trouble reaching the detailsection of a loaded subreport, in my mainreport contructor.

 

here is my subreport loading procedure:

 

   this.subLP5.ReportSource = new subLP5a();

//change pagebreak of subreport detailsection

     DetailSection ds = (DetailSection)this.subLP5.Report.Items["detaillp5a"];
     ds.PageBreak = PageBreak.None;

 

I get ds=null despite "detaillp5a" is the existing name for subLP5a detailsection.

Should I adress the detailarea in another manner?

 

regards

Mark

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Stef
Telerik team
answered on 25 Nov 2015, 05:41 PM
Hello Mark,

If you need to modify a report before displaying, the recommended approach is:
  1. Get an instance of the master report;
  2. Find the SubReport item;
  3. Extract an instance of the sub report from the SubReport item;
  4. Find the sub report's Detail section and modify it;
  5. Set again the SubReport item's ReportSource to the modified sub report instance;
  6. Display the master report;

For example:
InvoiceReport report = new InvoiceReport();
  
 
  
    //get the SubReport item
    var subReportItem = (Telerik.Reporting.SubReport)report.Items.Find("SubReport1", true)(0);
  
    //can be any type of report source
    var subReportItemReportSource = DirectCats(subReportItem.ReportSource, TypeReportSource);
    var typeName = typeReportSource.TypeName;
    var reportType = Type.GetType(typeName);
    //get the sub report instance
    var subReportInstance = (Report)Activator.CreateInstance(reportType);
  
    //update the sub report
    (subReportInstance.Items.Find("detail",true)[0] as Telerik.Reporting.DetailSection).PageBreak=.....;
  
    //set the updated sub report back to the SubReport item's ReportSource
    InstanceReportSource subIRS = new InstanceReportSource();
    subIRS.ReportDocument = subReportInstance;
    subReportItem.ReportSource = subIRS;
  
    //wrap the final report in a report source
    InstanceReportSource IRS = new InstanceReportSource();
    IRS.ReportDocument = report;


I hope this information is helpful.

Regards,
Stef
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 25 Nov 2015, 11:52 PM

Excellent.

Thanks for an elaborate answer!

 

 

Tags
General Discussions
Asked by
Mark
Top achievements
Rank 1
Answers by
Stef
Telerik team
Mark
Top achievements
Rank 1
Share this question
or