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

Access to items in SubReport

6 Answers 505 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fredrick Smith
Top achievements
Rank 1
Fredrick Smith asked on 06 Jun 2007, 07:13 PM
Hello,

First, let me say Telerik Reports has been great. I'm glad I switched from Crystal Reports.

Now my question is this. I have a report that displays details in a subreport. In the subreport. Each detail row has a set of values I need to access and then display a value based on those values. The problem is I don't know how to access the DataItems of the subreport so that I can extract the value that I need.

Thanks for your help,

Ricardo

6 Answers, 1 is accepted

Sort by
0
Feedback
Top achievements
Rank 1
answered on 06 Jun 2007, 09:29 PM
In my code, I created a reference to the "ReportSource" property of the SubReport.  This gave me the Report object, and I then used the Report's Items.Find method to get the Footer section (which I named upon creation).  Maybe you can do the same thing with the Details section?

// Find the subreport whose name is the value of "currentProductType" within the Master Report  
Telerik.Reporting.SubReport subreport_pointer = (Telerik.Reporting.SubReport)master_report.Items.Find(currentProductType, true)[0];  
 
// Get a pointer to that particular SubReport's Report object  
Telerik.Reporting.Report report_pointer = subreport_pointer.ReportSource;  
 
// Get the footer of the report, named "Footer_" + the value of "currentProductType"  
Telerik.Reporting.ReportFooterSection footer_pointer = (Telerik.Reporting.ReportFooterSection)report_pointer.Items.Find("Footer_" + currentProductType, true)[0];  
 
// Get the chart object that lives inside that report footer, where the chart's name is the value of "chart.Name"  
Telerik.Reporting.Chart chart_pointer = (Telerik.Reporting.Chart)footer_pointer.Items.Find(chart.Name, true)[0];  
 

Do you think this might work for you?

Matthew
0
Fredrick Smith
Top achievements
Rank 1
answered on 07 Jun 2007, 12:29 PM
I don't know, but I'll try it.

See, the problem is that I don't have the items (textboxes) displaying the value so basically what I need to do is access the items in the datasource for the current record of the being shown by the subreport.

Thanks for your help!

Ricardo
0
Svetoslav
Telerik team
answered on 07 Jun 2007, 03:49 PM
Hi Ricardo,

Depending of your needs you can experiment several things:
  • You can use the Report Header/Footer sections of the nested report to create some kind of totals or summaries for your sub report.
  • Since both ItemDataBinding and ItemDataBound events are public you can handle them from everywhere. Usually the master report instantiates the nested report and use this instance to pass it to the SubReport.ReportSource. So you can handle the subreport's DetailSection binding events (probably you need to expose this section making it public/internal) in the master report.
The two approaches above are just a small part of all possible solutions, and you should use the most suitable for your case.
 

All the best,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Fredrick Smith
Top achievements
Rank 1
answered on 07 Jun 2007, 05:26 PM
I think the second solution is what I'm shooting for.

The thing is, I don't know how to access the SubReport.

When I wire the "SubReport_ItemDataBound" event, I get a sender, which I can access, but only gives me access to the Parent Report and not the SubReport. I need some way of accessing the values inside the SubReport.
0
Fredrick Smith
Top achievements
Rank 1
answered on 07 Jun 2007, 08:37 PM
I'm using the following code:

private void caseDetailsSubReport_ItemDataBinding(object sender, EventArgs e) 
        { 
            CRSISDataSet CRSISDS = new CRSISDataSet(); 
            CRSISDataSetTableAdapters.CRSReportsTableAdapter reportsTA = new Reports.CRSISDataSetTableAdapters.CRSReportsTableAdapter(); 
             
            Telerik.Reporting.Processing.SubReport tempReport = (Telerik.Reporting.Processing.SubReport)sender; 
 
            DataRowView drv = (DataRowView)tempReport.DataItem; 
 
            int caseID = (int)drv.Row["ID"]; 
        } 

But I am NOT able to pull the SubReport's data using this method, this only pulls up the Main Report's data. I've tried using this method wired from the Main Report and from the SubReport's Document file code file (meaning from Parent.cs and from Child.cs), but it am NOT able to select the Child's DataItem to see its values.

Any help would be appreciated as this is a key feature in my reports.

Thanks,

Ricardo
0
Svetoslav
Telerik team
answered on 08 Jun 2007, 04:18 PM
Hello Ricardo,

Attached you may find a sample that demonstrates one of the possible ways to access the subreport's data from the master (outside) report.

For the purpose of the example I'm using a simple data tables filled in by hand.

The idea is as follows: the detail section of the nested report - DetailReport - was exposed (making in public) and inside the MasterReport I've handled the DetailReport detail section's ItemDataBound event.

Greetings,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Fredrick Smith
Top achievements
Rank 1
Answers by
Feedback
Top achievements
Rank 1
Fredrick Smith
Top achievements
Rank 1
Svetoslav
Telerik team
Share this question
or