pass datasource as a parameter

2 posts, 0 answers
  1. Francisco
    Francisco  avatar
    5 posts
    Member since:
    Jul 2016

    Posted 09 Sep Link to this post

        List<ReportVentasFamiliaDto> dataSource = new List<ReportVentasFamiliaDto>();
        dataSource.Add(new ReportVentasFamiliaDto()
        {
            PorcentajeIva = 10,
            FamiliaNombre = "Familia"
        });
     
     
        var objectDataSource = new Telerik.Reporting.ObjectDataSource();
        objectDataSource.DataSource = dataSource;
        objectDataSource.DataMember = "table1";
     
        var typeReportSource = new TypeReportSource() {
            TypeName = "Report1.trdp" };
        typeReportSource.Parameters.Add(new Parameter()
        {
            Name = "objectDataSource2",
            Value = objectDataSource
        });
        typeReportSource.Parameters.Add(new Parameter()
        {
            Name = "Text",
            Value = "valor"
        });
     
     
     
        }
     
    @(Html.TelerikReporting().ReportViewer()
            .Id("reportViewer1")
            .ServiceUrl(Url.Content("/api/reports/"))
            .TemplateUrl("/Resources/Templates/telerikReportViewerTemplate.html")
            .ReportSource(typeReportSource)
            .ViewMode(ViewMode.Interactive)
            .ScaleMode(ScaleMode.Specific)
            .Scale(1.0)
            .PersistSession(false)
            .PrintMode(PrintMode.AutoSelect)
    )

     

     

    How can I pass the datasoource as a parameter?

  2. Neli
    Admin
    Neli avatar
    190 posts

    Posted 12 Sep Link to this post

    Hello Francisco,

    I noticed that you have a TRDP report but you are trying to use TypeReportSource which is required for CS/VB reports. Reports created with the Standalone designer (TRDP/X files) may be passed with UriReportSource.

    Note that assigning the DataSource to the report or data items can be done in a  custom report resolver in the Reports Controller. You need to construct the report instance in the Resolve() method of the custom report resolver. Then the report has to be returned wrapped in an InstanceReportSource, which is the only server-side ReportSource that can take Report instance. DataSource cannot be passed through a Report Parameter.

    Generally, we do not recommend report definition modifications in run time. You may set the DataSource in the report definition. Note that the data source component does not actually hold any data. It only tells the Reporting engine where to fetch the data from. For the ObjectDataSource in run time, the Reporting engine will invoke the DataMember through System.Reflection to get the data. You may customize the received data by setting parameters to the ObjectDataSource.

    Regards,
    Neli
    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