This is a migrated thread and some comments may be shown as answers.

Issue Using InstanceReportSource

4 Answers 400 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 25 Nov 2013, 10:03 PM
Hi, I am using Telerik Reporting Q3 2013, and am trying to create a view model in an MVC application to display a report.  I am having an issue using the InstanceReportSource.

This works fine, and the report is displayed as expected (where "Report" in '_model.Report' is a custom class I have created to represent a report, and the parameters I enumerate are also custom classes that represent a report parameter in my report class, where the 'Value' property is a C# dynamic)....
                       
public ReportSource ReportSource
{
    get
    {
        // create the report source for the report
        var reportSource = new TypeReportSource
        {
            TypeName = _model.Report.TypeName + ", " + _model.Report.AssemblyName
        };
  
        // add all report parameters
        foreach (var parameter in _model.Parameters)
        {
            reportSource.Parameters.Add(parameter.Parameter.Name, parameter.Value);
        }
 
        // set a title parameter to the title of the user's report
        reportSource.Parameters.Add("Title", _model.Title);
 
        return reportSource;
    }
}

However, if I switch to using an InstanceReportSource, the report viewer just shows a "bad request" error...
public ReportSource ReportSource
        {
            get
            {
                // create the report source for the report
                var reportSource = new InstanceReportSource
                {
                    ReportDocument = new BidTabReportByStatus()
                };
 
                // add all report parameters
                foreach (var parameter in _model.Parameters)
                {
                    reportSource.Parameters.Add(parameter.Parameter.Name, parameter.Value);
                }
 
                // set a title parameter to the title of the user's report
                reportSource.Parameters.Add("Title", _model.Title);
 
                return reportSource;
            }
        }

In both cases, my view simply loads the report source property from the model...

@{
    // display the report
    @(Html.TelerikReporting().ReportViewer()
          .Id("reportViewer")
          .ServiceUrl("/api/reports/")
          .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
          .ReportSource(Model.ReportSource)
          .ViewMode(ViewModes.INTERACTIVE)
          .ScaleMode(ScaleModes.SPECIFIC)
          .Scale(1.0)
          .PersistSession(false))
}

Can you please help me figure out what is going on?  My ultimate goal is to be able to use one report for multiple data sets, by defining a sql command for the report's SqlDataSource 's CommandText property by defining it on the report source, which I can obtain using the instance report source.

Thanks,
Andy

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 28 Nov 2013, 10:39 AM
Hello Andy,

Due to some peculiarities regarding using report instances for reportsource we have decided initially not to support the InstanceReportSource. Still with the next internal build or service pack we will introduce official support for InstanceReportSource.

Regards,
Peter
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
James
Top achievements
Rank 1
answered on 29 Nov 2013, 03:14 PM
So does this mean that there is currently no way to use C# reports with the html5 report viewer? Setting the datasource to a TypeReportSource was only working for me using a trdx file.  

I tried something like this, where TestReport.cs was in the same repo as "Product Catalog.trdx", and "Product Catalog.trdx" worked fine

EDIT --
Oops, I was trying to pass the filepath instead of the assembly qualified name of my report.  All good now
   
Html.TelerikReporting().ReportViewer()
.Id("reportViewer1")
.ServiceUrl("/api/reports/")
.TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
.ReportSource(new TypeReportSource
     {
         TypeName = "TestReport.cs, CSharp.ReportLibrary"
     })
.ViewMode(ViewModes.INTERACTIVE)
.ScaleMode(ScaleModes.SPECIFIC)
.Scale(1.0)
.PersistSession(true)
0
faris
Top achievements
Rank 1
answered on 09 Jul 2014, 02:42 AM
u call from reportlibrary right? but we still need to create file.trdx?
can u post ur ReportsController?

thank you so much
0
Stef
Telerik team
answered on 11 Jul 2014, 08:56 AM
Hello Faris,

Please check my reply in the other forum thread you posted on the same question: Telerik reports with MVC 4.

If you have further questions, let us continue the discussion in the above linked thread in order to avoid splitting details between threads.

Regards,
Stef
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
General Discussions
Asked by
Scott
Top achievements
Rank 1
Answers by
Peter
Telerik team
James
Top achievements
Rank 1
faris
Top achievements
Rank 1
Stef
Telerik team
Share this question
or