WebDocumentViewerClientSideEventsBuilder.PreviewClick(String) Method
Specifies the JavaScript function that handles the Web Document Viewer’s PreviewClick client-side event.
Namespace: DevExpress.AspNetCore.Reporting.WebDocumentViewer
Assembly: DevExpress.AspNetCore.Reporting.v24.1.dll
NuGet Package: DevExpress.AspNetCore.Reporting
Declaration
Parameters
Name | Type | Description |
---|---|---|
callback | String | The name of a JavaScript handler function or the entire JavaScript function code. |
Returns
Type | Description |
---|---|
WebDocumentViewerClientSideEventsBuilder | A WebDocumentViewerClientSideEventsBuilder object that can be used to configure the Document Viewer client side events. |
Remarks
The PreviewClick event occurs when the user clicks a report document in the Web Document Viewer.
The handler function receives two parameters - the first parameter is the client-side Document Viewer (the event sender) and the second parameter is an object with the following properties and methods:
PageIndex
A zero-based index of the clicked page.Brick
A visual brick object that is related to the clicked report control.Handled
Specifies whether default event handling is required.DefaultHandler
A function that runs when the Handled field is set to false (the default value). You can call this function within your event handler and set the Handled field to true to prevent the function from being called twice.GetBrickText
Returns the text displayed in the clicked element (report brick).GetBrickValue
Returns additional information on the brick.
For more information on report bricks, review the following help topic: Bricks.
The following code demonstrates navigation between reports when the user clicks a report element. The e.GetBrickValue method returns the XRControl.Tag property value that contains the name of the report to open.
<script type="text/javascript" id="script">
function previewClick(s, e) {
var brickTag = e.GetBrickValue();
if (brickTag.includes("Report 1")) {
s.OpenReport("Report1");
e.Handled = true;
}
else {
if (brickTag.includes("Back")) {
s.OpenReport("MainReport");
e.Handled = true;
}
}
}
</script>
@{
var viewerRender = Html.DevExpress().WebDocumentViewer("DocumentViewer")
.Height("1000px")
.ClientSideEvents(configure => {
configure.PreviewClick("previewClick");
})
.Bind("MainReport");
@viewerRender.RenderHtml()
}