Telerik Reporting HTML5 pass parameters
Asked Answered
G

4

7

I've tried the MVC helper and the standard HTML5 viewer. I'm curious if anyone has been able to successfully load a report containing parameters using the new viewers. I cannot get any feedback from Telerik.

@{
    var report = new UriReportSource() { Uri = "TestReport.trdx" };
    report.Parameters.Add(new Telerik.Reporting.Parameter() { Name="UserId", Value=1234 });
    report.Parameters.Add(new Telerik.Reporting.Parameter() { Name = "UserName", Value = "Test User" });
}
@(Html.TelerikReporting().ReportViewer()
           .Id("reportViewer1")
           .ServiceUrl("/api/reports/")
           .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
               .ReportSource(report)
           .ViewMode(ViewModes.INTERACTIVE)
           .ScaleMode(ScaleModes.SPECIFIC)
           .Scale(1.0)
           .PersistSession(false)
        )
Galacto answered 4/11, 2013 at 16:35 Comment(5)
I asked them this also, and they refered me to documentation which unfortunately does not have this explained.Phiz
Same here, it got me stuck for 3 days. wondering maybe you can update with the answer?Ingalls
Have you found the solution to this yet?Trudy
Telerik's documentation is while(true) { awful }Weidar
Sorry, I don't even work for the same company anymore. I can tell you that I had more success when using their stand alone client to build their reports. I think I got that to work, but was still very problematic.Galacto
K
0

Wondering if you already tested How To: Pass values to report parameters in Telerik Reporting documents or not.

Kef answered 18/11, 2013 at 22:12 Comment(0)
C
0

You need to declare the report data source separately and then pass it for example

@{
       var dataSource = new UriReportSource() { Uri = "rptUncashedCheckLetter.trdx" };
        dataSource.Parameters.Add(new Telerik.Reporting.Parameter() { Name = "CheckNumber", Value = "2315527" });

    }

    @(Html.TelerikReporting().ReportViewer()
           .Id("reportViewer1")
           .ServiceUrl("/api/reports/")
           .TemplateUrl("/Reports/telerikReportViewerTemplate.html")
           .ReportSource(dataSource)
           .ViewMode(ViewModes.INTERACTIVE)
           .ScaleMode(ScaleModes.FIT_PAGE_WIDTH)
           .Scale(1.0)
           .PersistSession(false)
           )

There doesn't seem to be a way to do it directly when using the MVC version.

Coahuila answered 30/5, 2014 at 13:44 Comment(0)
F
0

In .cshtml as header you have @model yourModel

Then to create the report you have:

     UriReportSource urs = new UriReportSource (){
        Uri = "Report1.trdx" 
    };
    urs.Parameters.Add("id", Model.id.ToString());
    urs.Parameters.Add("start", Model.Start.ToString());
    urs.Parameters.Add("end", Model.Stop.ToString());

    @(Html.TelerikReporting().ReportViewer()
           .Id("reportViewer1")
           .ServiceUrl("/api/reports/")
           .TemplateUrl("/ReportViewer/templates/telerikReportViewerTemplate.html")
           .ReportSource(urs)
           .ViewMode(ViewModes.INTERACTIVE)
           .ScaleMode(ScaleModes.SPECIFIC)
           .Scale(1.0)
           .PersistSession(false))

And the Model.cs file:

 public class yourModel
{
    public Guid id{ get; set; }

    public DateTime Start { get; set; }

    public DateTime Stop { get; set; }}

This is the way i did it,hope it helps :)

Fields answered 5/6, 2014 at 8:10 Comment(0)
K
0

If all parameters were set, most probably the problem lies in the Newtonsoft.Json.dll. Your problematic project most probably references the GAC version of Newtonsoft. In order to fix check if Newtonsoft is still installed in the GAC and remove it if so. For a quick fix just delete the Newtonsoft reference from your project and add it using nuget.

Kobe answered 24/6, 2015 at 16:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.