How to pass a parameter to a report using typeResourceReport

2 posts, 0 answers
  1. Aubrey Ivan
    Aubrey Ivan avatar
    26 posts
    Member since:
    Oct 2019

    Posted 30 Oct 2019 Link to this post

    I am trying to pass a model to the report using typeReportResource to set it as its dataSource, am I doing this wrong?

    This is my Controller 

        public class ReportViewerController : Controller
            private IOrganisationLogic _organisationLogic;
            public ReportViewerController(IOrganisationLogic organisationLogic)
                _organisationLogic = organisationLogic;
            public ActionResult Index()
                var organisation = _organisationLogic.GetOrganisation();            

                var typeReportSource = new TypeReportSource();
                typeReportSource.TypeName = typeof(OrganisationSample).AssemblyQualifiedName;

                typeReportSource.Parameters.Add(new Parameter("flag", true));
                typeReportSource.Parameters.Add(new Parameter("organisation", organisation));

                return View(typeReportSource);


    And here is the report design that i've created...

        public partial class OrganisationSample : Telerik.Reporting.Report
            private IOrganisationLogic _organisationLogic;
            public OrganisationSample(bool flag, OrganisationLogic organisation)
                // Required for telerik Reporting designer support

                // TODO: Add any constructor code after InitializeComponent call

                if (flag)
                    this.DataSource = organisation;

    what is the best approach I could do? Iwant to set the objectDataSource dynamically, each report has its own objectDataSource and I just want a single viewer that can use render multiple reports.

  2. Nasko
    Nasko avatar
    1071 posts

    Posted 04 Nov 2019 Link to this post

    Hi Aubrey Ivan,

    It is not technically possible to pass arguments to the report constructor using a TypeReportSource. The parameter values in the TypeReportSource.Parameters collections are applied to the Report.Parameters, not the report's constructor arguments.

    We recommend that you set up a single ObjectDataSource component in the report. Then, modify the data retrieval using a data source parameter for each case.

    Progress Telerik

    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 Feedback Portal and vote to affect the priority of the items
Back to Top