This sample project shows how to localize the viewer. To select localization, it is enough to set the path to the localization XML file as the value of the
Localization
option.
First, you need to add the
StiNetCoreViewer
component to the view page. Also you need to pass the
StiNetCoreViewerOptions
object to the constructor. In the options you should set two actions -
GetReport
and
ViewerEvent
, which are located in the Actions options group. To localize the viewer, you should set the
Localization
option, the viewer component will automatically load and apply the specified localization:
@using Stimulsoft.Report.Mvc;
...
@Html.StiNetCoreViewer(new StiNetCoreViewerOptions()
{
Actions =
{
GetReport = "GetReport",
ViewerEvent = "ViewerEvent"
},
Localization = "Localization/de.xml"
})
The
OnPostGetReport
action loads the report and returns the 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. For example, load the rendered report file:
public IActionResult OnPostGetReport()
{
StiReport report = new StiReport();
report.LoadDocument(StiNetCoreHelper.MapPath(this, "Reports/SimpleList.mdc"));
return StiNetCoreViewer.GetReportResult(this, report);
}
The
ViewerEvent
action handles all the viewer events (switching pages, zooming, printing, exporting, interactivity, etc.) and returns the answer to the client using the
ViewerEventResult()
static method:
public IActionResult OnGetViewerEvent()
{
return StiNetCoreViewer.ViewerEventResult(this);
}
public IActionResult OnPostViewerEvent()
{
return StiNetCoreViewer.ViewerEventResult(this);
}
In the screenshot below you can see the result of the sample code: