Replicate row based on field

Stimulsoft Reports.NET discussion
Post Reply
THE V
Posts: 6
Joined: Mon Dec 10, 2007 4:40 pm
Location: California

Replicate row based on field

Post by THE V »

I was wondering if there was some way to use a field to replicate a data row.

For example I would like to take data like this..

Code: Select all

Plot   Name   Rep
101   Fred     5
102   Mike     2
103   Betty    3
And have an output in the report like this...

Code: Select all

Plot   Name
101   Fred  
101   Fred  
101   Fred  
101   Fred  
101   Fred  
102   Mike
102   Mike
103   Betty
103   Betty 
103   Betty 
I'm having to do this with hundreds of rows by insert - paste in excel and would like not to have to do this.

Thanks.
Vital
Posts: 1278
Joined: Fri Jun 09, 2006 4:04 am

Replicate row based on field

Post by Vital »

Hello,

You can use master-detail reports. Place two databands on page. Set MasterComponent of second databand to first databand. In BeforePrintEvent of first databand write following code:

Code: Select all

DataBand2.CountData = YourDataSource.Rep;
Thank you.
THE V
Posts: 6
Joined: Mon Dec 10, 2007 4:40 pm
Location: California

Replicate row based on field

Post by THE V »

Vital,

Thanks for the answer. Maybe I'm not doing it correctly but I can't seem to get it to work.

I have one datasource table "S" with these three fields in them.

Plot Name Rep


Both databands refer to "S"

If DataBand1 contains the print fields I just a get the same line repeated over and over again until I stop it.

If Databand2 has the print fields I get all of the data repeated over and over again until I stop it.

Is there a circular loop in the logic if I refer both bands to the same source which is causing the repeat to infinity?

I have not used the Master Detail functionality yet so I am unsure of it's requirements. The demo guide uses several datasources.



Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Replicate row based on field

Post by Edward »

Please refer only First DataBand to "S" datasource.

DataBand2.MasterComponent = DataBand1

Also please set DataBand1.PrintIfDetailEmpty = true;

DataBand1.Height = 0;

Please open the attached report in the Demo.exe example application.

Thank you.
Attachments
48.ReplicateTheRows.mrt
(15.5 KiB) Downloaded 151 times
THE V
Posts: 6
Joined: Mon Dec 10, 2007 4:40 pm
Location: California

Replicate row based on field

Post by THE V »

Thank you,

Now it works perfectly

Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Replicate row based on field

Post by Edward »

Please let us know if any help is required.

Thank you.
Post Reply