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

report problem

1 Answer 50 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
andrea
Top achievements
Rank 1
andrea asked on 20 Apr 2011, 01:46 PM
Hi,
I have to create a report for many item (animal), for each animal there are a header section with general information and a detail section with the list of birth (number of children, average weight etc..).

I use report parameter to pass the animal id from my silverlight application.

I start with report for single animal: in the header and footer I insert textbox with date and animal id, in detail section I insert general animal's informations and a table with list of birth.

As datasource I use my custom class Animal that contains general information and an List<BirthInformation> called ListBirth.

I create two datasource, ds1 for the report with Animal class and ds2 for the table with birth information setting datasource to Animal and DataMember to ListBirth. I had to make the second datasource for see the member of the list ListBirth

In the report's code I use NeedDatasource event, so on constructor I put the report datasource to null, and in the event handler I use the code:

Animal a = GetAnimal(id);
this.DataSource = a;
this.table4.DataSource = a.ListBirth;  

The report work fine.

Is this correct way to work?

I need now to make the report (single) form many animal whit a page break from an animal and the next, but I don't understand if I do to use a group or a new report with this report as subreport in a table and how to set the datasource.

Thank you very much.
andrea

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 26 Apr 2011, 01:16 PM
Hello andrea,

You can set table item datasource directly through binding with the following expression:
 Property Path Expression 
 Datasource  =ReportItem.DataObject.ListBirth

To merge multiple reports in one, our suggestion is to use a report book as shown in the following code snippet:
public class ReportBook : Telerik.Reporting.ReportBook
{
    public ReportBook()
    {
          
        var report1 = new AnimalReport();
        var report2 = new AnimalReport();
  
        this.Reports.Add(report1);
        this.Reports.Add(report2);
        Animal a1 = GetAnimal(1);
        Animal a2 = GetAnimal(2);
        this.Reports[0].DataSource = a1;
        this.Reports[0].DataSource = a2;

    }
}

All the best,
Peter
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
Tags
General Discussions
Asked by
andrea
Top achievements
Rank 1
Answers by
Peter
Telerik team
Share this question
or