The example below demonstrates how to handle the ParametersInitialized event to do the following:
- Initialize values of a visible and invisible parameter before the viewer loads the document.
- Change a parameter value in the panel's editor when a user assigns a value to another parameter.
How to Run the Example
Download the project and do the following:
- Update NuGet packages.
- Build and run the project.
- Navigate to the page that contains the document viewer.
Files to Review
Documentation
More Examples
Does this example address your development requirements/objectives?
(you will be redirected to DevExpress.com to submit your response)
Example Code
HTML<dx-report-viewer [reportUrl]="reportUrl" height="800px">
<dxrv-request-options [invokeAction]="invokeAction" [host]="hostUrl"></dxrv-request-options>
<dxrv-callbacks (ParametersInitialized)="OnParametersInitialized($event)"></dxrv-callbacks>
</dx-report-viewer>
TypeScriptimport { Component, Inject, ViewEncapsulation, ViewChild } from '@angular/core';
import { DxReportViewerComponent } from 'devexpress-reporting-angular';
@Component({
selector: 'report-viewer',
encapsulation: ViewEncapsulation.None,
templateUrl: './report-viewer.html',
styleUrls: [
"../../../node_modules/devextreme/dist/css/dx.common.css",
"../../../node_modules/devextreme/dist/css/dx.light.css",
"../../../node_modules/@devexpress/analytics-core/dist/css/dx-analytics.common.css",
"../../../node_modules/@devexpress/analytics-core/dist/css/dx-analytics.light.css",
"../../../node_modules/devexpress-reporting/dist/css/dx-webdocumentviewer.css"
]
})
export class ReportViewerComponent {
@ViewChild(DxReportViewerComponent, { static: false })
viewer!: DxReportViewerComponent;
reportUrl: string = "XtraReport1";
invokeAction: string = '/DXXRDV';
OnParametersInitialized(event: any) {
// Specify an invisible integer parameter's value on viewer initialization.
var invisibleIntParamValue = 42;
var intParam = event.args.ActualParametersInfo.filter(
(x: any) => x.parameterDescriptor.name == "intParam")[0];
intParam.value = invisibleIntParamValue;
// Specify a visible Boolean parameter's value on viewer initialization.
var visibleBooleanParamValue = true;
var booleanParam = event.args.ActualParametersInfo.filter(
(x: any) => x.parameterDescriptor.name == "booleanParam")[0];
booleanParam.value = visibleBooleanParamValue;
// Update a string parameter value when a user changes the Boolean parameter value.
var strParam = event.args.ActualParametersInfo.filter(
(x: any) => x.parameterDescriptor.name == "strParam")[0];
booleanParam && booleanParam.events.on('propertyChanged', (args: any) => {
if (args.propertyName === 'value') {
strParam.value = args.newVal.toString();
}
});
intParam & booleanParam & strParam && event.args.Submit();
}
constructor(@Inject('BASE_URL') public hostUrl: string) { }
}