x
ActiveReportsJS v5.2 is Here! Check out our newest update. ActiveReportsJS v5.2 is Here! ARJS 5.2 is Here!

How do you access Report Parameter Values of Subreport incase of Dynamic Data

Posted by: vasudev.potla on 13 May 2020, 5:01 pm EST

    • Post Options:
    • Link

    Posted 13 May 2020, 5:01 pm EST

    I would like filter data I set to subreport based on ReportParameter Values of Subreport. My question is how do I access subreport parameter values through LocateDataSourceEventArgs type.

                var data = await _someService.Get(id);
    
                string rptPath = HostingEnvironment.MapPath("/Reports/MainRpt.rdlx");
                GrapeCity.ActiveReports.PageReport rpt = new GrapeCity.ActiveReports.PageReport();
                rpt.Load(new System.IO.FileInfo(rptPath));
                //PesoCodeRpt rpt = new PesoCodeRpt();
                GrapeCity.ActiveReports.Document.PageDocument myDocument = new GrapeCity.ActiveReports.Document.PageDocument(rpt);
                Subreport subreport = (Subreport)((List)rpt.Report.Body.ReportItems["List1"]).ReportItems["Subreport1"];
                subreport.ReportName = Path.GetFullPath(HostingEnvironment.MapPath("/Reports/SubRpt.rdlx"));
                myDocument.LocateDataSource += new LocateDataSourceEventHandler((object sender, GrapeCity.ActiveReports.LocateDataSourceEventArgs args) =>
                {
                    var x = args.Report.Name;
                    if (args.Report.Name.Contains("SubRpt.rdlx"))
                    {
                        var paramss = args.Report.ReportParameters;
                    }
                    else
                    {
                        args.Data = data;
                    }
                });
    

    thank you for your prompt response.

  • Posted 14 May 2020, 9:42 am EST - Updated 30 September 2022, 5:12 pm EST

    Hello,

    You can’t access the subreport parameter in the locatedatasource. However, you can create parameter in the parent report and map the parameter with subreport parameter through parameters property of subreport control. Please refer to the attached image.

    Thanks,

    Mohit

  • Posted 14 May 2020, 9:55 am EST

    Yes, thats how did set the sub report parameters. And as we can set the data for subreport through locatedatasource, we thought we can access sub report parameters values and set filtered the data to subreport.

    I have a different question, I am setting the main report to a Object, example

    var MainObj = [
    {"Name": Vasu, Job:"Developer", PayHistory:[{x:1, y:2,z:[]},{x:1,y3,z:[]}]},
    {"Name": Ramesh, Job:"Manager", PayHistory:[{x:1, y:2,z:[]},{x:1,y3,z:[]}]},
    ]
    
    

    Is there a way to pass an Array of objects like PayHistory from the above example to subreport from main report?

  • Posted 20 May 2020, 7:14 am EST

    Hello,

    I am very sorry for the delay!

    Yes, it is possible to pass the array of object to the subreport. Please refer to the attached project.

    Thanks,

    Mohit

    Project_ObjectDataSource.zip

  • Posted 20 February 2025, 7:50 am EST

    Can I also access the field values from Sub-Report to Main Report? Or if I can have more than one data-sources in a report?

    Sometimes I need to bind a single field of Main report but from other query than what I use in Main report.

  • Posted 21 February 2025, 12:06 am EST

    Hi Anoop,

    Yes, you can bind a Page/RDLX Report to multiple data sources. Please see the attached sample.

    We hope this helps!

    MainReport.zip

  • Posted 21 February 2025, 5:51 am EST

    Actually no, I meant to section report (.rpx )

    I have a field in my Main Report and want to bind this from other datasource rather than the Main datasource. How I can do it. I have more than 1 fields, so I don’t want to use Sub-reports for every field.

    Thanks

  • Posted 21 February 2025, 6:05 am EST

    Hi Anoop,

    Unfortunately, you can only use a single datasource in Section Report. The only possible solution is to use subreports for different data sources or use a Page/RDLX report.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels