Dynamic Parameter Hiding and Parameter Panel Height Control by JS

  • Last update:March 25, 2025
  • Overview

    Version

    Report Server Version

    Functional Change

    11.0

    -

    Expected Effect

    When developing reports, you often need to use multiple parameter widgets in a report. In this case, you can hide some widgets that are not commonly used or do not need to be displayed, and display them when they need to be displayed, as shown in the following figure.

    iconNote:

    1. When the report is frozen, this solution does not have a good adaptive effect in Pagination Preview. You are recommended to use other preview methods.

    2. When multiple sheets exist in data entry, the code for hiding parameters will cause the sheet label to move up, which will affect the aesthetics. You are not recommended to use this solution in this scenario.

     Implementation Method

    Add a Click event for Button Widget to hide or show the specified other type of widgets when the button is clicked.

    Example

    Widget Adding

    Create a template and add multiple widgets on the parameter panel, as shown in the following figure.

    image 21.png

    Widget Name Modifying

    1. Change the button names of button1 and button3 on the parameter panel to View All Parameters and Hide All Parameters respectively, as shown in the following figure.

    image 22.png

    2. Set Widget Name to a, b, c, d, e, f of the widgets in the last row of the parameter panel respectively to simplify the JS code added later, as shown in the following figure.

    iconNote:
    You can make no changes here, and just add the corresponding widget name in the JS code added later.

    image 23.png

    Click Event Adding

    1. Add a Click event for the View All Parameters button. Select the button and add a Click event under Widget Settings > Event on the right, as shown in the following figure.

    image 24.png

    The JavaScript codes are as follows:

    var a = this.options.form.getWidgetByName("a");
    var b = this.options.form.getWidgetByName("b");
    var c = this.options.form.getWidgetByName("c");
    var d = this.options.form.getWidgetByName("d");
    var e = this.options.form.getWidgetByName("e");
    var f = this.options.form.getWidgetByName("f");
    a.setVisible(true);
    b.setVisible(true);
    c.setVisible(true);
    d.setVisible(true);
    e.setVisible(true);
    f.setVisible(true);
    if (!window.originalParameterContainerHeightBackup) {
    window.originalParameterContainerHeightBackup = FR.parameterContainerHeight;
    window.originalContentContainerHeightBackup = $('#content-container').height();
    FR.tempParameterContainerHeight = 105;
    window.tempContentContainerHeightBackup = window.originalContentContainerHeightBackup + window.originalParameterContainerHeightBackup - FR.tempParameterContainerHeight;
    }
    setTimeout(function({
    $('.parameter-container').css('height'window.originalParameterContainerHeightBackup);
    $('#content-container').css('top'window.originalParameterContainerHeightBackup);
    $('#content-container').css('height'window.originalContentContainerHeightBackup);
    FR.parameterContainerHeight = window.originalParameterContainerHeightBackup;
    if (contentPane) {
    var $frozen;
    var $tempContentPane;
    if (contentPane.$contentPane) {
    $tempContentPane = contentPane.$contentPane;
    }
    if (contentPane.curLGP && contentPane.curLGP.$sheet_container) {
    $tempContentPane = contentPane.curLGP.$sheet_container;
    }
    if ($tempContentPane) {
    $frozen = $(".frozen-table", $tempContentPane);
    }
    if ($frozen && $frozen.length > 0) {
    FR.layoutFrozen($tempContentPane, $tempContentPane.offset().top);
    }
    }

    }, 1000);
    Show Code

    2. Add a Click event for the Hide All Parameters button. Select the button and add a Click event under Widget Settings > Event on the right, as shown in the following figure.

    image 25.png

    The JavaScript codes are as follows:

    iconNote:
    When multiple sheets exist in data entry, the code for hiding parameters will cause the sheet label to move up, which will affect the aesthetics. You are not recommended to use this solution in this scenario.
    var a = this.options.form.getWidgetByName("a");
    var b = this.options.form.getWidgetByName("b");
    var c = this.options.form.getWidgetByName("c");
    var d = this.options.form.getWidgetByName("d");
    var e = this.options.form.getWidgetByName("e");
    var f = this.options.form.getWidgetByName("f");
    a.setVisible(false);
    b.setVisible(false);
    c.setVisible(false);
    d.setVisible(false);
    e.setVisible(false);
    f.setVisible(false);
    if (!window.originalParameterContainerHeightBackup) {
    window.originalParameterContainerHeightBackup = FR.parameterContainerHeight;
    window.originalContentContainerHeightBackup = $('#content-container').height();
    FR.tempParameterContainerHeight = 105;
    window.tempContentContainerHeightBackup = window.originalContentContainerHeightBackup + window.originalParameterContainerHeightBackup - FR.tempParameterContainerHeight;
    }
    setTimeout(function({
    $('.parameter-container').css('height', FR.tempParameterContainerHeight);
    FR.parameterContainerHeight = FR.tempParameterContainerHeight;
    $('#content-container').css('top', FR.tempParameterContainerHeight);
    $('#content-container').css('height'window.tempContentContainerHeightBackup);
    if (contentPane) {
    var $frozen;
    var $tempContentPane;
    if (contentPane.$contentPane) {
    $tempContentPane = contentPane.$contentPane;
    }
    if (contentPane.curLGP && contentPane.curLGP.$sheet_container) {
    $tempContentPane = contentPane.curLGP.$sheet_container;
    }
    if ($tempContentPane) {
    $frozen = $(".frozen-table", $tempContentPane);
    }
    if ($frozen && $frozen.length > 0) {
    FR.layoutFrozen($tempContentPane, $tempContentPane.offset().top);
    }
    }
    }, 1000);
    Show Code

    Preview Effect

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

    1.gif

    iconNote:
    The effect cannot be previewed on mobile terminals.

    Template Download

    Attachment List


    Theme: Parameter
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

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

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

    不再提示

    6s后關閉

    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