Skip to main content
All docs
V22.1

WebDocumentViewerClientSideEventsBuilder.ParametersInitialized(String) Method

Specifies the JavaScript function that handles the client-side ParametersInitialized event and allows you to get the client-side parameter values when they are initialized and modify them.

Namespace: DevExpress.AspNetCore.Reporting.WebDocumentViewer

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

Declaration

public WebDocumentViewerClientSideEventsBuilder ParametersInitialized(
    string callback
)

Parameters

Name Type Description
callback String

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

Returns

Type Description
WebDocumentViewerClientSideEventsBuilder

The WebDocumentViewerClientSideEventsBuilder object that can be used for method chaining.

Remarks

The ParametersInitialized event allows you to get the client-side parameter values when they are initialized, subscribe to their changes, and fill parameter editors with custom parameter values.

The handler function receives two arguments - the first argument is the client-side DocumentViewer object (Preview if the ReportDesigner event is handled), the second argument is the object with the following properties and methods:

ActualParametersInfo
An array of objects with information about parameters. Each object contains the following properties and methods:
  • parameterDescriptor - an object with the IParameterDescriptor interface. It contains a parameter description and indicates whether a parameter has lookup values.
  • lookupValues - returns a ko.ObservableArray<IDisplayedValue> array of the parameter lookup values {value, displayValue}.
  • value - returns the ko.Observable | ko.Computed parameter value. You can subscribe to this value to handle user action when the user changes the parameter value in the editor.
Submit
A method that initiates document generation.
ShouldRequestParameters
Returns true if the report’s RequestParameters property is true and the report has at least one visible parameter. Otherwise, the property returns false.

Example - Initialize Invisible Parameter

You can use the ParametersInitialized event to set the value of the report parameter that is not displayed in the Preview Parameters panel. The following code sets the parameter value after the Viewer loads the report, but before the Viewer creates and displays the document. The code calls the Submit method to generate the document after the specified parameter value is applied to the report.

function onParametersInitialized(s, e) {
    var p1 = e.ActualParametersInfo
        .filter(x => x.parameterDescriptor.name == "parameter1")[0];
    p1.value(100);
    p1 && e.Submit();
}

Example - Cascading Parameters

The following code filters lookup values of the Person2 parameter based on the value selected for the Person1 parameter:

function ParametersInitialized(sender, args) {
    var parameter1 = args.ActualParametersInfo.filter(
        x => x.parameterDescriptor.name == "Person1")[0];
    var parameter2 = args.ActualParametersInfo.filter(
        x => x.parameterDescriptor.name == "Person2")[0];
    var preValue = null;
    parameter1 && parameter1.value.subscribe(function (newVal) {
        var lookUps = parameter2.lookUpValues().filter(
            x => x.value != newVal);
        preValue && lookUps.push(preValue);
        preValue = parameter2.lookUpValues().filter(
            x => x.value == newVal)[0];
        lookUps = lookUps.sort((x, y) =>
            (x.value > y.value) ? 1 : (x.value < y.value) ? -1 : 0);
        parameter2.lookUpValues(lookUps);
    });
    parameter1 && parameter2 && args.Submit();
}
See Also