Back to Devexpress

DxReportViewer.ShouldDisposeReport Property

xtrareports-devexpress-dot-blazor-dot-reporting-dot-dxreportviewer-9ceb563a.md

latest2.3 KB
Original Source

DxReportViewer.ShouldDisposeReport Property

Specifies whether a report should be disposed of when the Report Viewer is closed.

Namespace : DevExpress.Blazor.Reporting

Assembly : DevExpress.Blazor.Reporting.v25.2.Viewer.dll

NuGet Package : DevExpress.Blazor.Reporting.Viewer

Declaration

csharp
public bool ShouldDisposeReport { get; set; }
vb
Public Property ShouldDisposeReport As Boolean

Property Value

TypeDescription
Boolean

true to dispose of the report when the viewer is closed; otherwise, false.

|

Remarks

The ShouldDisposeReport setting determines whether the report is disposed of when the viewer is closed. The default value is true.

The ShouldDisposeReport property is not marked with the [Parameter] attribute, so you cannot set it in Razor markup. To change this property, use a component reference and assign the value in code.

The following code snippet sets the ShouldDisposeReport property to false and prevents the report from being disposed of when the viewer is closed. When you set this property to false, you should manually dispose of the report to avoid memory leaks:

razor
@page "/"

<DxReportViewer @ref="reportViewer" Report="@Report" />

@code {
    DxReportViewer reportViewer;
    XtraReport Report = new XtraReport1();
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        await base.OnAfterRenderAsync(firstRender);
        if (reportViewer != null) reportViewer.ShouldDisposeReport = false;
    }

    public void Dispose() {
        Report.Dispose();
        Report = null;
    }
}

See Also

DxReportViewer Class

DxReportViewer Members

DevExpress.Blazor.Reporting Namespace