Page 1 of 1

Set subreport datasource from databand

Posted: Mon Dec 02, 2013 2:04 am
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

Re: Set subreport datasource from databand

Posted: Tue Dec 03, 2013 1:57 am
by poweredbyporkers
Anyone??

Re: Set subreport datasource from databand

Posted: Tue Dec 03, 2013 10:55 am
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.

Re: Set subreport datasource from databand

Posted: Fri Nov 10, 2017 3:13 am
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?

Re: Set subreport datasource from databand

Posted: Mon Nov 13, 2017 9:10 pm
by Alex K.
Hello,

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

Thank you.

Re: Set subreport datasource from databand

Posted: Fri Nov 17, 2017 12:24 am
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

Re: Set subreport datasource from databand

Posted: Fri Nov 17, 2017 7:39 pm
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.

Re: Set subreport datasource from databand

Posted: Mon Nov 20, 2017 12:13 am
by vineet
Thanks, that works!

Re: Set subreport datasource from databand

Posted: Mon Nov 20, 2017 3:58 am
by Andrew
Hello,

Thank you for letting us know about this.