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)....
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...
In both cases, my view simply loads the report source property from the model...
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
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