ASPxClientWebDocumentViewer.PreviewClick Event

Occurs when the left mouse button is clicked on a report document.

Namespace: DevExpress.XtraReports.Web.Scripts

Assembly: DevExpress.XtraReports.v18.1.Web.Scripts.dll

Syntax

public event ASPxClientWebDocumentViewerPreviewClickEventHandler PreviewClick

The event handler receives an argument of the ASPxClientWebDocumentViewerPreviewClickEventHandler type.

Handle the PreviewClick event to perform different actions when an end-user clicks the report document opened in the Web Document Viewer. You can obtain a text displayed by the corresponding report element using the ASPxClientPreviewClickEventArgs.GetBrickText method and additional brick information (the XRControl.Tag property value) using the ASPxClientPreviewClickEventArgs.GetBrickValue method.

The following code snippet demonstrates how to obtain the text of an element that has been clicked.

<script type="text/javascript" id="script">
    function previewClick(s, e) {
        e.Brick && alert(e.Brick.text())
    }
</script>

<dx:ASPxWebDocumentViewer ID="ASPxWebDocumentViewer1" runat="server" ReportSourceId="WebReportDesigner.XtraReport1">
     <ClientSideEvents PreviewClick="previewClick"/>
</dx:ASPxWebDocumentViewer>

The example below illustrates how to ask the user to confirm an operation related to expanding/collapsing data in a drill-down report and navigating to an URL. The ASPxClientWebDocumentViewerBrick.navigation property provides access to a brick's navigation settings. Use the ASPxClientPreviewClickEventArgs.Handled property to specify whether or not default processing (specified by the ASPxClientPreviewClickEventArgs.DefaultHandler function) is required, depending on the confirmation result.

<script type="text/javascript" id="script">
    function previewClick(s, e) {
        if (!e.Brick)
            return
        var navigation = e.Brick.navigation;
        if (navigation) {
            var ok = true;
            if (navigation.drillDownKey) {
                ok = confirm('Are you sure you want to expand/collapse data?');
            } else if (navigation.url) {
                ok = confirm('Are you sure you want to navigate to the following URL: ' + navigation.url);
            }
            e.Handled = !ok;
        }
    }
</script>

<dx:ASPxWebDocumentViewer ID="ASPxWebDocumentViewer1" runat="server" ReportSourceId="WebReportDesigner.XtraReport1">
     <ClientSideEvents PreviewClick="previewClick"/>
</dx:ASPxWebDocumentViewer>