How to Destroy the Report Viewer Object

To destroy the Bold Reports® Blazor Report Viewer object, add a DisposeReportsObject function to the boldreports-interop.js file and invoke it through JavaScript interop when the Razor component is disposed.

  1. Add the following code in the boldreports-interop.js file to destroy the Report Viewer object.

    window.DisposeReportsObject = () => {
        var reportViewerElement = document.querySelector('.e-reportviewer.e-js');
        if (reportViewerElement) {
            //Destroy the report viewer processing objects.
            $(reportViewerElement).data('boldReportViewer').destroy();
        }
        return true;
    }
  2. Invoke the DisposeReportsObject function in the Pages/Index.razor file, as in the following code:

    @page "/"
    
    @implements IDisposable
    
    @code {
        void IDisposable.Dispose()
        {
            // Unsubscribe from the event when our component is disposed
            JSRuntime.InvokeAsync<bool>("DisposeReportsObject").GetAwaiter();
        }
    }

See also