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

ReportBook get parameters from request

5 Answers 214 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mathieu
Top achievements
Rank 1
Mathieu asked on 08 Sep 2015, 01:32 PM

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

Sort by
0
Accepted
Stef
Telerik team
answered on 08 Sep 2015, 03:13 PM
Hello Mathieu,

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
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
0
Mathieu
Top achievements
Rank 1
answered on 09 Sep 2015, 04:37 PM

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

0
Travis Lamkin
Top achievements
Rank 1
answered on 16 Oct 2015, 07:04 PM

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)"}

0
Travis Lamkin
Top achievements
Rank 1
answered on 16 Oct 2015, 07:08 PM
By "Pages", I meant different reports.
0
Stef
Telerik team
answered on 21 Oct 2015, 04:30 PM
Hello Travis,

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
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
Tags
General Discussions
Asked by
Mathieu
Top achievements
Rank 1
Answers by
Stef
Telerik team
Mathieu
Top achievements
Rank 1
Travis Lamkin
Top achievements
Rank 1
Share this question
or