Accessing report's variables from the controller
Accessing report's variables from the controller
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.
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.
-
- Posts: 975
- Joined: Tue Sep 07, 2021 10:11 am
Re: Accessing report's variables from the controller
Hello,
Please check the following link with example project:
https://github.com/stimulsoft/Samples-R ... 0in%20Code
Thank you.
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
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.
Re: Accessing report's variables from the controller
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);
}
-
- Posts: 975
- Joined: Tue Sep 07, 2021 10:11 am
Re: Accessing report's variables from the controller
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.
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
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.
John W
Code: Select all
Dim dt As DataTable = report.Dictionary.GetDataSet("newLicenseRpt").Tables(0)
John W
-
- Posts: 1
- Joined: Thu Oct 03, 2024 3:53 am
-
- Posts: 975
- Joined: Tue Sep 07, 2021 10:11 am
Re: Accessing report's variables from the controller
Hello,
You are Welcome!
You are Welcome!