Skip to main content
A newer version of this page is available. .

WebDocumentViewerClientSideEventsBuilder.DocumentReady(String) Method

Sets the name of the JavaScript function or the entire code that will handle the Web Document Viewer’s DocumentReady client-side event.

Namespace: DevExpress.AspNetCore.Reporting.WebDocumentViewer

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

NuGet Package: DevExpress.AspNetCore.Reporting

Declaration

public WebDocumentViewerClientSideEventsBuilder DocumentReady(
    string callback
)

Parameters

Name Type Description
callback String

The name of a JavaScript function or the entire JavaScript function code used to handle the DocumentReady event.

Returns

Type Description
WebDocumentViewerClientSideEventsBuilder

A WebDocumentViewerClientSideEventsBuilder object that can be used to further configure the Document Viewer client side events.

Remarks

The DocumentReady event enables you to respond to loading a report to the Document Viewer. When implementing a handler function, use the objects passed as parameters. The first parameter passes the event sender that is the ClientDocumentViewer object. The second one is an object with the following structure.

  • ReportId
    The report ID.

  • DocumentId
    The ID of the document that is ready to be shown in the Web Document Viewer.

  • PageCount
    The total number of pages in a report document.

Example: Page Navigation

The code sample below demonstrates how to navigate through pages of a document when it is created.

<script type="text/javascript" id="script"> 
    function documentReady(s, e) {
        var previewModel = s.GetPreviewModel();
        var goToNextPage = function () {
            var pageIndex = previewModel.GetCurrentPageIndex();
            if (e.PageCount <= pageIndex)
                return;
            previewModel.GoToPage(pageIndex + 1);
            setTimeout(function () { goToNextPage(); }, 3000);
        }
        goToNextPage();
    }
</script>

@{
    var documentViewer = Html.DevExpress().WebDocumentViewer("webDocumentViewer1")
        .Height("1000px")
        .Bind(Model.Report)
        .ClientSideEvents(configure => { configure.DocumentReady("documentReady"); });;
}
@documentViewer

Example: Show the Document Map Panel Automatically

The following code sample shows the Document Map Panel when the Document Viewer has loaded a report and the document has been built:

@{
    var viewerRender = Html.DevExpress().WebDocumentViewer("DocumentViewer")
        .Height("1000px")
        .ClientSideEvents(configure =>
        {
            configure.DocumentReady(@"function(s, e) {
                var preview = s.GetPreviewModel();
                if (preview)
                {
                    preview.tabPanel.tabs[3].active(true);
                }
            }
            ");
        })
    .Bind("TestReport");
    @viewerRender.RenderHtml()
}
See Also