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

Creating Master-Detail Reports using DataSets

2 Answers 234 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Søren
Top achievements
Rank 1
Søren asked on 30 Jan 2009, 02:35 PM
Dear Community,

We are currently strugling with some issues related to the Master-Details reports when using DataSets as data source. We have so far tried to follow and convert the Telerik examble http://www.telerik.com/help/reporting/designingreportsmasterdetail.html to fit our needs, however we seem to have run in to some problems along the way. To keep our problem simple, we have created a simple forms application containing a report viewer and some sample data to feed into the reports.

Our first problem is mainly getting the DataSet data to work with the detail page. So far, we have all our data in the load method of the form:

private void Form1_Load(object sender, EventArgs e)

 

{ ... }

We then create a new object of the MasterReport and bind the dataset to the report. This works, however we still lack to fill data onto th detail report, any idea on how to complete this sort of task?

Our second problem is getting the filtering to work properly. I have followed the guide from Telerik step-by-step, however the result is either no output, or output without filtering.

If someone have experience with using these kinds of reports based on e.g. a dataset (or basicly anything else besides the Telerik Report Wizard), it would be great with some assistance - code examples are much appreciated.

Kind regards,
S. Engel

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 30 Jan 2009, 04:36 PM
Hello Søren,

You should attach to the NeedDataSource event of the SubReport item. The event will be fired for each row from the master table and you will be able to set the data source of your sub-report. I hope that the following code snippet will help you solve the issue:

using Processing = Telerik.Reporting.Processing;

private void subReport1_NeedDataSource(object sender, System.EventArgs e)
{
    Processing.SubReport subReport = (Processing.SubReport)sender;
    DataRowView rowView = (DataRowView) subReport.DataItem;
    //here you would probably use some primary key column from the current master row (rowView) to select all matching detail rows, but you can data bind in any way you desire
    subReport.InnerReport.DataSource = <<your data source for the sub-report goes here>>
}


This is the event handler for the NeedDataSource event of the SubReport item which contains your sub-report.

If you want to to this from your calling application, you can get a hold of the subreport item and bind its report like this:

Telerik.Reporting.SubReport subRepItem1 = ReportViewer1.Report.Items.Find("SubReport1", true)[0] as Telerik.Reporting.SubReport;
subRepItem1.ReportSource.DataSource = <your_dataset>;


Let me know if you have any further questions or that is not the case you are after.

Regards,
Steve
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Søren
Top achievements
Rank 1
answered on 03 Feb 2009, 02:32 PM
Hi Steve,

Thanks for your reply. A couple hours later, after I posted the thread, I got the problems fixed. I didn't use the snippet you supplied, however I can see it might be a more efficient way of solving the problem. Anyhow, the problem is now fixed, but I will look into your solution in the nearest future.

Thanks,
Søren
Tags
General Discussions
Asked by
Søren
Top achievements
Rank 1
Answers by
Steve
Telerik team
Søren
Top achievements
Rank 1
Share this question
or