Pass parameters to GetReportData method

Stimulsoft Reports.WEB discussion
Post Reply
Stéphane
Posts: 12
Joined: Fri Jun 30, 2017 11:32 am

Pass parameters to GetReportData method

Post by Stéphane »

Hello,

I'm evaluating Stimulsoft.Reports.NetCore. I didn't find how I can pass a parameter (a property of my model) from the View into the GetReportData method of my controller. Any idea ?
In the controller, perhaps I must use the StiNetCoreViewer.GetRequestParams method but I don't see how I can set a variable into these parameters from my view code.

Cordially,
Stéphane.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Re: Pass parameters to GetReportData method

Post by Edward »

Hi Stéphane,

Please check the following page:

https://www.stimulsoft.com/en/documenta ... g_data.htm

And also please check the SQL data sources option in that page.

This is also a method of passing some report parameters:
https://www.stimulsoft.com/en/documenta ... viewer.htm
https://www.stimulsoft.com/en/documenta ... meters.htm

Could you please explain more about your task, what exactly you are trying to send from view and the controller?

Thank you,
Edward
Stéphane
Posts: 12
Joined: Fri Jun 30, 2017 11:32 am

Re: Pass parameters to GetReportData method

Post by Stéphane »

Yes, I looked at the documentation. In fact, in our ASP.Net Core business application, there is a complex UI where the user can filter and sort a datasource. So, I want to pass this filter (or directly the filtered datasource) to the Stimulsoft report. I didn't find how I can pass these parameters directly to the StiNetCoreViewer component. The mode of operation seems inverted, the StiNetCoreViewer asks for the report name and the datasource but we can't set these parameters directly from the view. I can put these parameters to a memory cache and use it in GetReport and GetReportData methods of the controller but I think there is a better way (that I didn't find).
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Pass parameters to GetReportData method

Post by Alex K. »

Hello,

You can use two ways:
1. Send parameters in the GET request and read them in the Action of the viewer:
public IActionResult GetReportData(string paramName)
{
...
}

2. Save parameters in the server session and then read them in the viewer actions.

Thank you.
mb0101
Posts: 1
Joined: Thu Jun 20, 2019 8:46 pm

Re: Pass parameters to GetReportData method

Post by mb0101 »

Has any other solution been created for this need? We too need to pass parameters and a token to the report viewer, but passing this in a query string is poor practice. Is there no other way to load a POST request with the report parms and request?
Lech Kulikowski
Posts: 6239
Joined: Tue Mar 20, 2018 5:34 am

Re: Pass parameters to GetReportData method

Post by Lech Kulikowski »

Hello,

You can set the following viewer's option:

Code: Select all

Server =
{
    PassFormValues = true
}
and then get all POST parameters in any action of the viewer with the following code:

Code: Select all

 var formValues = StiNetCoreViewer.GetFormValues(this);
Thank you.
Post Reply