Hello,
I have a question regarding ReportBook. I send a request like that in JS after a click on a button :
.telerik_ReportViewer({
serviceUrl: apiUrl,
templateUrl: reportUrl,
reportSource: {
report: "Reports.Controlling.Controlling, Reports",
parameters: params
}
});
In an standard report I can access parameters with this line :
var report = (Report)sender;
var parameter1 = Convert.ToInt32(((object[]) (report.Parameters[BusConstants.ParamOfferId].Value))[0]);
Now I want to do the same with a reportBook. For example, get the paramters and do that :
if(parameter1)
Reports.Add(new RegionRevenue(parameter1));
else
{
Reports.Add(new ProductPartCosts(parameter2));
Reports.Add(new ServicePerformanceCostReport());
}
Is it possible (to get parameters the same way and use them to instanciate books) ? Cause I've seen this thread and I think that's not possible : http://www.telerik.com/forums/reports-with-document-map-excel-sheet
Thank you for your help.
Mathieu
5 Answers, 1 is accepted
Report parameters values sent by the client are applied over the already resolved report document. Thus they cannot be used for the dynamic generation of a ReportBook.
Instead you can use a custom report resolver for the Reporting REST service and work with the string description sent by the viewer's reportSource.report. The string can contain the names of the reports you want to add or other information that can be handled in the resolver.
I hope the provided information is helpful.
Regards,
Stef
Telerik
Hello Stef,
Thanks for your help, after testing the report resolver solution, it works.
I send my parameters from view in JSON, defined the class ReportsControllingController exactly like the example, and finally created this class :
public class CustomReportResolver : Telerik.Reporting.Services.Engine.IReportResolver
{
public Telerik.Reporting.ReportSource Resolve(string reportParameters)
{
return new ControllingTab(reportParameters);
}
}
I send parameters from request in my ControllingTab, who check them to launch corresponding reports.
Thank you for your help !
Mathieu
We just upgraded to the most recent Telerik version. We have a ReportBook in our system that could have different number of pages depending on data. What we think is happening, is that the report format is getting cached somewhere and reused, but due to the different number of pages, the Index out of range exception is thrown (we see that as a 500 error while capturing the network traffic).
{"message":"","exceptionMessage":"Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index","exceptionType":"Telerik.Reporting.Services.Engine.DocumentRenderException","stackTrace":" at Telerik.Reporting.Services.Engine.Document.GetDocumentInfo()\r\n at Telerik.Reporting.Services.Engine.ReportEngine.GetDocumentInfo(String clientID, String instanceID, String documentID)\r\n at Telerik.Reporting.Services.WebApi.ReportsControllerBase.GetDocumentInfo(String clientID, String instanceID, String documentID)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass13.<GetExecutor>b__c(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)"}
We are currently investigating the issue based on the provided by you project, but the scenario is not correctly set. The mechanism used for changing the ReportBook object produces different ReportBook objects on each call of the resolver, and initially there are 3 calls for registering the client, the instance and obtaining parameters - on each of these calls the ReportBook object must be the same, and the counter in your examples changes the content.
We will appreciate it if we continue the discussion in your support thread on the same question. If anyone experiencing the same problem has a demo project, please open a support ticket and send it to us for further tests.
Regards,
Stef
Telerik