Clicking the Button on the Parameter Panel to Display or Hide Data by JS

  • Last update:July 03, 2025
  • Overview

    Version

    Report Server VersionFunctional Change
    11.0/

    Problem

    When a report contains excessive list data, you may want to use a display button to hide the detailed data and display only the statistics, as shown in the following figure. How to achieve the effect?

    Implementation Method

    You can use JavaScript to modify the value of the parameter widget and add a condition attribute to the cell to display or hide the corresponding row according to the parameter value.

    Example

    Template Preparation

    Prepare the built-in template Group_Summary.cpt in %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Primary\GroupReport.

    For details, you can download the template Group_Summary.cpt.

    The following figure shows the template style.

    Widget Adding

    1. Add a label widget to the parameter panel, set Widget Name to label, deselect Visible, and set Widget Value to show, as shown in the following figure.

    2. Add a button widget to the parameter panel, set Widget Name to button, and set Button Name to Only show total data, as shown in the following figure.

    Event Adding

    Select the button widget, and add a Click event for the widget. The content of the event is to change the value of the label widget and modify the button name when you click the button, as shown in the following figure.

    The JavaScript code is as follows.

    /* Obtain the value of the hidden label widget */
    var label= this.options.form.getWidgetByName("label").getValue();
    /* Check the value of the label widget */
    if (label == 'show') {
    {
    /*Modify the value of the label widget to hide when the widget value is show, and modify the button name to show all data.*/
    this.options.form.getWidgetByName("label").setValue("hide");
    this.options.form.getWidgetByName("button").setValue("show all data");
    }
    else
    {
    /*Modify the value of the label widget to show when the widget value is not show, and modify the button name to only show total data.*/
    this.options.form.getWidgetByName("label").setValue("show");        
    this.options.form.getWidgetByName("button").setValue("only show total data");
    }
    /* Execute the query */
    _g().parameterCommit();

    Adding a Condition Attribute

    Return to the report design page, right-click cell B3, and select Condition Attribute. To add a condition attribute for cell B3, set Row Height to 0 mm and add the formula condition $label = 'Hide'. The formula condition means to hide cell B3 when the value of the label widget is hide. Otherwise, cell B3 will be displayed, as shown in the following figure.

    Effect Display

    Click the blank area of the parameter panel, and deselect Display Nothing Before Query. In this case, the report content is displayed upon initialization without clicking Query.

    Save the template and click Pagination Preview. The following figure shows the effect on the PC.

    iconNote:
    The effect cannot be previewed on mobile terminals.

    Template Download

    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