Controlling Attributes of Toolbar Buttons Through JS

  • Last update:January 17, 2025
  • Overview

    Version

    Report Server VersionFunctional Change
    11.0

    /

    Expected Effect

    For data entry reports, the attributes (such as visibility and availability) of specific buttons on the toolbar can be changed during report review or after successful submission to avoid accidental operations. For example, after successful submission, the Print and Email functions are disabled, as shown in the following figure.

    Screen Recording 2025-01-17 at 14.23.31 (1).gif

    Implementation Method

    Choose Template > Web Attribute > Data Entry Setting, add a Data Entry Successful event, and use JavaScript codes to set the availability or visibility of a button according to its name.

    For details about JS APIs related to the toolbar, see Toolbar API.

    Example

    Template Preparation

    Prepare a data entry template.

    Event Addition

    Open the template, choose Template > Web Attribute > Data Entry Setting, set Following Settings to Set for This Template Separately, and add a Data Entry Successful event, as shown in the following figure.

    2025-01-17_14-19-30.png

    The JavaScript codes are as follows:

    iconNote:
    1. When setting attributes of the toolbar buttons, ensure that the button triggering the current event remains enabled. In this example, the Submit button should not be disabled.

    2. The widget name of the Email button is email, and the widget name of the Print button is newprint. For details, see getWidgetByName.

    _g().getToolbar().getWidgetByName("email").setEnable(false);
    _g().getToolbar().getWidgetByName("newprint").setEnable(false);

    To disable specific buttons during initialization, you can add a Loading End event and include a delay function in the code, as shown in the following figure.

    setTimeout(function(){
    _g().getToolbar().getWidgetByName("email").setEnable(false);
    _g().getToolbar().getWidgetByName("newprint").setEnable(false);
    },1000);

    Effect Display

    Save the template and click Data Entry Preview. The preview effect is shown in section "Expected Effect."

    iconNote:
    The effect cannot be previewed on mobile terminals.

    Template Download

    For details, you can download the template Controlling Attributes of Toolbar Buttons Through JS.cpt.


    Attachment List


    Theme: Report Application
    • Helpful
    • Not helpful
    • Only read

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

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

    不再提示

    8s后關閉

    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