Successfully!

Error!

You are viewing 10.0 help doc. More details are displayed in the latest help doc

JS Assign Values to Parameter Widgets

I. Overview

1.1 Requirement

The parameter pane must provide a widget to dynamically control the values of other widgets, as shown below. When the username is not null, the parameter value of the state automatically goes to 1. When the username is null, the parameter value of the state automatically goes to 2.

 


1.2 Solution

Get and assign the widget value through JavaScript.

II. Sample

Here’s a sample for your reference.


2.1 parameter pane

1) Create a new template, click [Menu Template]>[Template Parameter], and add two template parameters respectively named username and state:

 

2) Open the parameter pane and click [Add All Buttons] in the right-handed [Widget Setting] pane:

 

3) Set the two undefined widgets as Drop-Down Box widget and Radio Button Group widget:

 

4) Select the username, click […] in [Data Dictionary], and the [Data Dictionary] setup pane will pop up. Set the [Type] as [Custom] and add jerny, anna and merry respectively into the Actual Value and the Display Value.

 

5) Select the state, click […] in [Data Dictionary], and the [Data Dictionary] setup pane will pop up. Set the [Type] as [Custom] and add 1 and 2 respectively into the Actual Value and the Display Value.

 

 

2.2 Add a JS event to the Drop-down Box Widget

Select the username and add an After Editing event, as shown in the figure below:

 

Input the following JS codes:

var state = this.options.form.getWidgetByName("state");
var username = this.options.form.getWidgetByName("username").getValue();
if(!username) {
     state.setValue(2);
} else {
    state.setValue(1);
}

Note

The above JS code is used to configure parameter settings to the state. When the username is null, !username is true, and the parameter value of the state is 2; or else when the username is not null, the parameter value of the state is 1.

 

2.3 Preview

Save the template and click [Pagination Preview]. The preview effect on a PC is shown as below:

 

III. Download the template

Attachment List


Theme: Secondary Development
Already the First
Already the Last
  • Helpful
  • Not helpful
  • Only read

Doc Feedback