JS Assign Values to Parameter Widgets

  • Last update:  2020-12-15
  • 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: Parameter
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy