JS Use Buttons to Switch Report Background Colors

  • Last update:  2020-12-17
  • I. Description

    In order to improve the visual effect of reports, JS can be used to dynamically switch the background color of the report.

    II. Ideas

    When designing the report, add a button widget in the parameter pane, and add a JS click event to the button to dynamically switch the background color of the report.

    III. Examples

    1) Open the sample report in the attachment, place a query widget in the left area of the parameter pane, insert the label widget and five buttons in the right area as shown in the figure below, and modify their widget names.

    1606380156220440.png

    2) Set the Click events of the five buttons separately. Take LavenderBlush as an example, select the fifth button, add a Click event to the button, and write the following JS code:

    setTimeout(function() {
        $(".content-container").css("background-color", "LavenderBlush");
    }, 100)

    Note: "LavenderBlush"in the code is the color code of lavender blush, and for other buttons, you only need to modify the color code here. For example: to set a red button, just copy this code and change "LavenderBlush" to "Red".

    1606380220274593.png

    IV. Effect preview

    The preview effect on the PC side is shown in the figure below:

    1606380249267389.gif

    Note: Mobile terminal is not supported

    V. Completed Template

    Attachment List


    Theme: Secondary Development
    • 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