JS Show or Hide Data by Clicking the Parameter Pane Button

  • Last update:  2021-01-06
  • I. Overview

    1.1 Requirement

    When too many tabular data are present in the report, how to hide detailed data and only display statistics by using button widget?

     


    1.2 Solution

    Use JavaScript to modify the value of parameter widget. Show or hide corresponding rows by setting the conditional formatting.

    II. Sample

    2.1 Design a template

    1) Add a label widget and set the Widget Name as label and uncheck Visible. Set the Widget Value as Show.

     

    2) Add a button widget, and set the Widget Name as button and the Widget Value as “Only show total data”.

     

    3) Select the button widget and add a click event, as shown in the figure below:

     

    Input the JS code:

    /*Get the value of hidden label widget */
    var label = this.options.form.getWidgetByName("label").getValue();
    /* Define the value of label widget*/
    if (label == 'show') {
           /* When the value of label widget is set as Show, modify it to Hide, and set the Button Name as Show All Data*/
           this.options.form.getWidgetByName("label").setValue("hide");
           this.options.form.getWidgetByName("button").setValue("show all data");
    } else {
           /* When the value of label widget is set as Hide, modify it to Show, and set the Button Name as Only Show Total Data*/
           this.options.form.getWidgetByName("label").setValue("show");
           this.options.form.getWidgetByName("button").setValue("only show total data");
    }
    /*Execute query*/
    _g().parameterCommit();

    4) Click the white space of the parameter pane, and uncheck Display Nothing Before Query.

     

    5) Return to the design interface and right click B3 to add conditional formatting. Set the Row Height as 0mm, and define the Formula as $label = 'hide'.

     


    2.2 Preview

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

     


    2.3 Download the template

    Show or Hide Data by Click the Parameter Pane Button.cpt


    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