Set up the report viewer in .NET 8.0, load a template, and connect the component to the application.

Client-side events. The Vue component emits events, so you subscribe with the @event directive and pass your own handler functions:
<script setup lang="ts">
import { StimulsoftViewer } from 'stimulsoft-viewer-vue';

function loaded(): void {
    console.log('Report loaded');
}

function onExport(event: any): void {
    console.log(`Export to: ${event.format}`);
}
</script>

<template>
    <StimulsoftViewer
        request-url="/Viewer/{action}"
        action="InitViewer"
        height="100vh"
        @loaded="loaded"
        @export="onExport"
    />
</template>

Two events are handled here: @loaded fires once the report has been rendered and is ready, and @export fires when the user exports the report — the event object carries details such as the target format. The same pattern works for other viewer events (printing, interaction, e-mail, and more); simply add the corresponding @... handler.

Server-side handling. Interactive events that need the server are routed to the ViewerEvent action, registered in the options during initialization:
public IActionResult InitViewer()
{
    var requestParams = StiVueViewer.GetRequestParams(this);

    var options = new StiVueViewerOptions();
    options.Actions.GetReport = "GetReport";
    options.Actions.ViewerEvent = "ViewerEvent";

    return StiVueViewer.ViewerDataResult(requestParams, options);
}

[HttpPost]
public IActionResult ViewerEvent()
{
    return StiVueViewer.ViewerEventResult(this);
}

The StiVueViewer.ViewerEventResult helper processes the incoming event and returns the result the viewer expects, so server-side actions such as export and print work out of the box.

Используя этот сайт, вы соглашаетесь на использование файлов Cookie для аналитики и персонализированного контента. Файлы Cookie хранят полезную информацию на вашем компьютере, чтобы помочь нам повысить эффективность и удобство использования. Для получения дополнительной информации, пожалуйста, прочтите Конфиденциальность и Использование Cookie.