Skip to main content

WebDocumentViewerClientSideEventsBuilder.BeforeRender(String) Method

Specifies the JavaScript function that handles the client-side BeforeRender event.

Namespace: DevExpress.AspNetCore.Reporting.WebDocumentViewer

Assembly: DevExpress.AspNetCore.Reporting.v22.2.dll

NuGet Package: DevExpress.AspNetCore.Reporting


public WebDocumentViewerClientSideEventsBuilder BeforeRender(
    string callback


Name Type Description
callback String

The name of a JavaScript function or entire JavaScript function code that runs when the BeforeRender event occurs.


Type Description

WebDocumentViewerClientSideEventsBuilder that can be used for method chaining.


Handle the BeforeRender event to customize the Web Document Viewer’s View Model before it is bound to an HTML element and/or Knockout binding is activated.

The handler function receives two parameters. The first parameter is the object that exposes the IPreviewModel interface (or the JSReportViewer object). The second is the Document Viewer model that allows you to adjust the control’s settings.

The following code snippet sets the zoom level to 25%, enables multi-page mode, and indicates the moment when the first page is loaded:

<div id="loader"> <div id="loaderText" > </div> </div>
<script type="text/javascript" id="script" >
function onBeforeRender(s, e) {
    $("#loaderText").text("Waiting for the first page..");
    $("#loader").dialog({ title: "Document Viewer", hide: { delay: 1000 } });
    //Get a property that contains the document's page information. 
    var pages = e.reportPreview.pages;
    //Subscribe to property change. 
    var pagesSubscription = pages.subscribe(function (newValue) {
        if (newValue.length > 0) {
            //Stop tracking changes.

    var viewerRender = Html.DevExpress().WebDocumentViewer("DocumentViewer")
        .ClientSideEvents(configure => configure.BeforeRender("onBeforeRender"))
See Also