JS Show or Hide Parameter Widget by Switching Tabs

  • Last update:January 06, 2021
  • I. Overview

    1.1 Requirement

    Produce a tab-type report. In the tab-type report, some parameters displayed in the parameter pane may be hidden by clicking a certain tab.

    Click TITLE 1 to display the parameters of ORDER ID only; and click TITLE 0 to display the parameters both of ORDER ID and SHIPPER:

     


    1.2 Solution

    Add an After Initialization Event on the body component, and use the setTimeout function in the JavaScript to monitor the event status of the tab. Due to failure to get the tab, we use eq to bind the Tab component to the Click Event by using jQuery class selector.

    II. Sample

    2.1 Add parameters

    1) Click Template>Template Parameter to add two parameters. Name them as ORDER ID and SHIPPER respectively, as shown below:

     

    2) Drag the parameter pane into the report body, click the white space of the parameter pane, and select [ADD ALL] in the right pane of Widget Setting:

     


    2.2 Add a tab

    Drag the Tab block into the report body and add a Tab:

     


    2.3 Add an After Initialization Event

    1) Click the second Tab to hide the SHIPPER Widget and click the first Tab to show the SHIPPER Widget.

    Select the body widget at the upper right corner to add an After Initialization Event:

     

    Input the JS code:

    setTimeout(function({
           $(".fr-widget-click").eq(2).bind("click"function({
                  $("div[widgetname$='SHIPPER']").show();
           });
           $(".fr-widget-click").eq(3).bind("click"function({
                  $("div[widgetname$='SHIPPER']").hide();
           });
    }, 100);

    Note

    If the Widget Name is in English, it should be capitalized, otherwise it cannot be recognized.

    2) Select tabpane and add a Tab Switch Event, as shown below:

     

    Input the JS code:

    var tabpane = this.getWidgetByName("TABPANE0");
    switch (tabpane.mouseInTab) {
           case 0:
                  $("div[widgetname$='SHIPPER']").show();
                  break;
           case 1:
                  $("div[widgetname$='SHIPPER']").hide();
                  break;
           default:
                  break;
    }

    III. Preview

    Save the templates and select [Dashboard Preview]. The preview effect is as shown below:

    III. Download the template

    Attachment List


    Theme: FineVis Data Visualization
    • 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