pass datasource as a parameter

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

    Posted 09 Sep 2019 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
    273 posts

    Posted 12 Sep 2019 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
  3. Rajeev
    Rajeev avatar
    1 posts
    Member since:
    May 2014

    Posted 06 Feb in reply to Neli Link to this post

    Hi Neli, could you provide a complete example or point to one on how to bind a List to the report. This is the problem I am running into. I have a report bound to a sqldatasource and currently running fine. However, this particular report can be run only once since last run in order to see the data changes. So after running the report if the user tries to export the data to pdf, selecting that option from the dropdown on the report toolbar, the pdf is blank since the report is being effectively run again and there are no changes since the last run (which is a few seconds ago). Does this make sense? So I need to get the data once and bind it to the report, so that the export to pdf also will bind to the same data and display the data (rather than execute the stored pro again and come out blank). Let e know if you need more info. I am also using a TypeReportSource.
  4. Neli
    Admin
    Neli avatar
    273 posts

    Posted 11 Feb Link to this post

    Hi Rajeev,

    I suggest to open a new Support Ticket where you can attach the problematic application or just a sample project on which the behavior is reproducible. Note that it is not necessary to contain real data but it has to be runnable. Then we can investigate it further.

    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