Skip to main content

WebDocumentViewerClientSideEventsBuilder.CustomizeElements(String) Method

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

Namespace: DevExpress.AspNetCore.Reporting.WebDocumentViewer

Assembly: DevExpress.AspNetCore.Reporting.v24.1.dll

NuGet Package: DevExpress.AspNetCore.Reporting

Declaration

public WebDocumentViewerClientSideEventsBuilder CustomizeElements(
    string callback
)

Parameters

Name Type Description
callback String

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

Returns

Type Description
WebDocumentViewerClientSideEventsBuilder

WebDocumentViewerClientSideEventsBuilder that can be used for method chaining.

Remarks

The CustomizeElements event allows you to customize the Web Document Viewer’s UI elements.

The handler function receives two parameters. The first parameter is the object that exposes the IPreviewModel interface (or the JSReportViewer object). The second parameter contains the following properties and methods:

  • Elements. A collection of the UI elements included in the Web Document Viewer.
  • GetById. This method returns the Web Document Viewer visual element by its ID. The ID is one of the following DevExpress.Reporting.Viewer.PreviewElements enumeration members:
    • RightPanel - the Tab panel at the right of the Viewer.
    • Surface - the Viewer’s central section that displays the report document.
    • Toolbar - the Document Viewer’s Toolbar.

The code sample below demonstrates how to use this event to hide the Web Document Viewer’s Toolbar.

<script type="text/javascript" id="script"> 
  function customizeElements(s, e) {
      var toolbarPart = e.GetById(
        DevExpress.Reporting.Viewer.PreviewElements.Toolbar);
      var index = e.Elements.indexOf(toolbarPart);
      e.Elements.splice(index, 1);
  }
</script>

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