This example shows how to change viewer options from the controller.

First, you need to add the StiNetCoreViewer component to the view page:
@using Stimulsoft.Report.Mvc;

...

@Html.StiNetCoreViewer(@ViewBag.ViewerOptions as StiNetCoreViewerOptions)

In the options above we define several actions, and we need to add it in the controller.

The GetReport() action loads the report template and returns answer to the client part of the viewer using the GetReportResult() static method. In the parameters of this method, the report object should be passed:
public IActionResult GetReport()
{
	// Create the report object
	var report = new StiReport();

	// Load report snapshot
	report.LoadDocument(StiNetCoreHelper.MapPath(this, "Reports/SimpleList.mdc"));

	return StiNetCoreViewer.GetReportResult(this, report);
}

...

To return result, use ViewerEventResult() method:
...

public IActionResult ViewerEvent()
{
	return StiNetCoreViewer.ViewerEventResult(this);
}

...

Finally, use StiNetCoreViewerOptions() method to change viewer options:
...

public IActionResult Index()
{
	var viewerOptions = new StiNetCoreViewerOptions();
	viewerOptions.Actions.GetReport = "GetReport";
	viewerOptions.Actions.ViewerEvent = "ViewerEvent";
	viewerOptions.Appearance.FullScreenMode = true;
	viewerOptions.Toolbar.Zoom = 75;
	viewerOptions.Toolbar.ViewMode = Stimulsoft.Report.Web.StiWebViewMode.MultiplePages;
	viewerOptions.Theme = Stimulsoft.Report.Web.StiViewerTheme.Office2013WhiteViolet;

	// Passing options via ViewBag
	ViewBag.ViewerOptions = viewerOptions;

	return View();
}

In the screenshot below you can see the result of the sample code:

Changing the Viewer Options from the Controller

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.