Set subreport datasource from databand

Stimulsoft Reports.WEB discussion
Post Reply
User avatar
poweredbyporkers
Posts: 28
Joined: Fri Nov 29, 2013 8:42 pm

Set subreport datasource from databand

Post by poweredbyporkers »

I seem to be talking to myself, but hopefully someone will eventually answer something.... ;)

I have a SQL statement that returns listing data and has a couple of the columns defined as XML fragments that contains many items, i.e. multiple cultures and translations. This is to remove the problem when I have 1 master row with 3 cultures and translations and 10 external codes. Normal SQL will return multiple rows of data obviously and it's really difficult maintain on the report. I have a routine that converts the XML fragment into a data table but I can't work out how to assign this data table at run time to the sub-report. I need to run this routine on each data row and assign the data source.

In Summary

Each data row that is output I need to get the Cultures column from the data source convert it into a datatable and assign that datatable as the datasource on the sub-report. I can't use relations
User avatar
poweredbyporkers
Posts: 28
Joined: Fri Nov 29, 2013 8:42 pm

Re: Set subreport datasource from databand

Post by poweredbyporkers »

Anyone??
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Set subreport datasource from databand

Post by HighAley »

Hello.

Here is a sample report template. You could find code in the Before Print event of the DataCategories band.
It's possible to change this code and load XML that you need for your report.

Thank you.
Attachments
Runtime dataTable creation.mrt
(8.34 KiB) Downloaded 306 times
vineet
Posts: 69
Joined: Fri Nov 10, 2017 3:12 am

Re: Set subreport datasource from databand

Post by vineet »

How do I set sub report's data source if my current data source is coming from a business object and the sub report is present in an external file?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Set subreport datasource from databand

Post by Alex K. »

Hello,

Could you explain your issue in more details?
Also, please clarify which product and version are you use?

Thank you.
vineet
Posts: 69
Joined: Fri Nov 10, 2017 3:12 am

Re: Set subreport datasource from databand

Post by vineet »

Hi Alex,

I am using 2017.2. I have an external sub-report .mrt file. And a parent .mrt file.

My parent has data source from business object configured in the data sources section. Now when I try to add the sub-report, I can't find a way to pass the data source of the parent to the sub-report. Can I modify any events (before/after print) to pass the data?

Cheers
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Set subreport datasource from databand

Post by HighAley »

Hello,

You could handle the GetSubReport event and register you business objects there.

Code: Select all

            StiReport rep = new StiReport();
            rep.LoadFromUrl(@"D:\MainReport.mrt");
            rep.GetSubReport += new StiGetSubReportEventHandler(rep_GetSubReport);
            rep.Render();
            rep.Show();
                        .....
                        

        void rep_GetSubReport(object sender, StiGetSubReportEventArgs e)
        {
            StiReport rep = new StiReport();
            rep.LoadFromUrl(@"D:\SubReport.mrt");
            rep.RegData(ds);
            e.Report = rep;
        }
Thank you.
vineet
Posts: 69
Joined: Fri Nov 10, 2017 3:12 am

Re: Set subreport datasource from databand

Post by vineet »

Thanks, that works!
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Re: Set subreport datasource from databand

Post by Andrew »

Hello,

Thank you for letting us know about this.
Post Reply