Back to Devexpress

DxReportViewer.OnPreviewClick Event

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

latest2.3 KB
Original Source

DxReportViewer.OnPreviewClick Event

Occurs when a user clicks a report document.

Namespace : DevExpress.Blazor.Reporting

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

NuGet Package : DevExpress.Blazor.Reporting.Viewer

Declaration

csharp
[Parameter]
public EventCallback<PreviewClickEventArgs> OnPreviewClick { get; set; }
vb
<Parameter>
Public Property OnPreviewClick As EventCallback(Of PreviewClickEventArgs)

Parameters

TypeDescription
PreviewClickEventArgs

The event data.

|

Remarks

The following code snippet handles the OnPreviewClick event. The sample report contains two labels (“Label 1” and “Label 2”). The Clicked variable displays the clicked label caption or “Empty area”. When “Label 2” is clicked, the Handled property is set to true to prevent any default actions.

razor
@using DevExpress.Blazor.Reporting.Models
@using DevExpress.XtraReports.UI
@using DxBlazorApplication.PredefinedReports

<div>Clicked: @Clicked</div>

<DxReportViewer Report="@Report"
                OnPreviewClick="OnPreviewClick"/>

@code {
    private string? Clicked;
    XtraReport Report = new TestReport(); // Contains "Label 1" and "Label 2"

    private async Task OnPreviewClick(PreviewClickEventArgs args) {
        if (args.Brick is null) {
            Clicked = "Empty area";
            return;
        }
        else if (args.Brick.Text == "Label 1") {
            Clicked = "First Label";
            return;
        }
        else if (args.Brick.Text == "Label 2") {
            Clicked = "Second Label";
            args.Handled = true;
            return;
        }

        await Task.CompletedTask;
    }
}

See Also

DxReportViewer Class

DxReportViewer Members

DevExpress.Blazor.Reporting Namespace