JS Automatically Switch between Tabs

  • Last update:December 16, 2020
  • I. Overview

    1.1 Requirement

    If there is a dashboard with multiple Tab pages, how to automatically switch between these Tab pages?

     


    1.2 Solution

    Method 1: The Tab layout provides the tablayout object with the function of automatic rotation of Tab pages, which can be directly set in the [Attributes], as shown in the figure below:

     

    Method 2: Add an After Initialization event through JavaScript to enable the jumping from one Tab page to the next Tab page at regular intervals, so that these Tab pages will be automatically rotated.

    II. Solution

    2.1 Settings of a JS event

    Click [Widget Setting], select [body] in the drop-down list, and add an After Initialization event in the right pane, as shown in the figure below:

     

    Input the following JS codes:

    setInterval(function() {
        var aa = _g().getWidgetByName("tabpane0").getShowIndex();
        if(aa == 3) {
            _g().getWidgetByName('tabpane0').showCardByIndex(0);
            //If the 4th Tab block is currently displayed, jump to the 1st Tab block
        } else {
            _g().getWidgetByName('tabpane0').showCardByIndex(aa + 1);
            //If the 1st-3rd Tab blocks are currently displayed, jump to the next Tab block correspondingly
        }
    }, 2000);

    Note

    tabpane0 represents the name of the Tab block; and index() represents the title index.

     

    2.2 Preview

    III. Download the template

    Attachment List


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