Page 1 of 1
Accessing report's variables from the controller
Posted: Tue Oct 01, 2024 8:30 am
by Evokati
So, I have a .net 6 MVC application.
I created a report with several variables. What I want to achieve is:
1. Display the report viewer to the user
2. Let him enter these variables (report parameters)
3. When he presses "Submit", I want to access the variables the user entered inside the controller and retrieve appropriate data
4. Display the report to the user.
How can I do that? Specifically, I don't understand how to access the report's variables from the controller.
Re: Accessing report's variables from the controller
Posted: Tue Oct 01, 2024 12:12 pm
by Max Shamanov
Hello,
Please check the following link with example project:
https://github.com/stimulsoft/Samples-R ... 0in%20Code
Thank you.
Re: Accessing report's variables from the controller
Posted: Tue Oct 01, 2024 2:52 pm
by Evokati
Yeah, I saw that already. But in this example the parameters are taken from a custom form and then assigned to the report. While I want to do kind of the opposite - get these parameters from the report after user entered them in the viewer and clicked submit.

- sti viewer parameters.png (11.11 KiB) Viewed 3255 times
Re: Accessing report's variables from the controller
Posted: Wed Oct 02, 2024 8:56 am
by Evokati
Ok, I think I got it. I can use the ViewerInteraction action:
Code: Select all
public async Task<IActionResult> ViewerInteraction()
{
StiRequestParams requestParams = StiNetCoreViewer.GetRequestParams(this);
if (requestParams.Action == StiAction.Variables)
{
var startDate = requestParams.Interaction.Variables["StartDate"];
// Do something
}
return StiNetCoreViewer.InteractionResult(this);
}
Re: Accessing report's variables from the controller
Posted: Wed Oct 02, 2024 11:53 am
by Max Shamanov
Hello,
Yes, you can try to use the viewer events.
Please check the following link with documentation:
https://www.stimulsoft.com/en/documenta ... meters.htm
Thank you.
Re: Accessing report's variables from the controller
Posted: Wed Oct 02, 2024 3:20 pm
by JohnW
I don't know if this is helpful but can read them for the report dataset. I load the dataset into a datatable in code and then script out what I want to do. Once it is in the table you can do just about anything that may be needed.
Code: Select all
Dim dt As DataTable = report.Dictionary.GetDataSet("newLicenseRpt").Tables(0)
John W
Re: Accessing report's variables from the controller
Posted: Thu Oct 03, 2024 4:03 am
by jessieleon
It helps me
Re: Accessing report's variables from the controller
Posted: Thu Oct 03, 2024 6:06 am
by Max Shamanov
Hello,
You are Welcome!