Clicking the Button to Switch Sheet by JS

  • Last update:March 25, 2025
  • Overview

    Version

    Report Server Version

    Functional Change

    11.0

    -

    Problem

    When there are multiple sheets in a report, you can jump to a specified Sheet page through clicking the button on the parameter panel, as shown in the following figure.

    1.gif

    Implementation Method

    This effect is achieved by adding JS events to the buttons on the parameter panel and positioning the corresponding Sheet in the events.

    Example

    Template Preparation

    1. Create a template and add four Button Widget items on the parameter panel. The widget names are First Page, Previous Page, Next Page, and Last Page, as shown in the following figure.

    image 59.png

    2. Click the parameter panel of the template and deselect Display Nothing Before Query, as shown in the following figure.

    image 60.png

    3. Add multiple Sheet pages and add red identification statements in each Sheet page, as shown in the following figure.

    image 61.png

    Event Adding

    1. Select Button Widget on the first page and add a Click event to it. Then you can click the button to jump to Sheet1 page, as shown in the following figure.

    image 62.png

    The JavaScript codes are as follows:

    //Jump to the first page (because the subscript starts from 0). fr-sheetbutton-container specifies the sheet collection.
    $(".fr-sheetbutton-container").eq(0).trigger("click");

    2. Use the same method to add the Click events to the widget buttons of the previous page, next page, and last page. The event content is as follows:

    JavaScript codes of Previous Page are as follows:

    //Get the collection length. fr-sheetbutton-container specifies the sheet collection. 
    var len = $(".fr-sheetbutton-container").length;
    //Get the subscript of the currently-selected sheet.
    var index = $(".fr-sheetbutton-container").index($(".fr-sheetbutton-container-active"));
    //If the current subscript is 0, the page is the first page.
    if(index > 0) {
    //Jump from the non-first-page page to the previous page.
        $(".fr-sheetbutton-container").eq(index - 1).trigger("click");
    }else{
    //Jump from the current first page to the last page. (Because the subscript starts from 0, the length needs to be reduced by 1.) 
    $(".fr-sheetbutton-container").eq(len - 1).trigger("click");
    }

    JavaScript codes of Next Page are as follows:

    //Get the collection length. fr-sheetbutton-container specifies the sheet collection.
    var len = $(".fr-sheetbutton-container").length;
    // Get the subscript of the currently-selected sheet(because the subscript starts from 0).
    var index = $(".fr-sheetbutton-container").index($(".fr-sheetbutton-container-active"));
    if(index < len) {
    //If the index of the current subscript is 1 less than the value of len, the page is the last page. 
        if(index == (len - 1)) {
           //Jump from the current last page to the first page.
            $(".fr-sheetbutton-container").eq(0).trigger("click");
        } else {
           //Jump from the non-last-page page to the next page. 
            $(".fr-sheetbutton-container").eq(index + 1).trigger("click");
        }
    }

    Show Code

    JavaScript codes of Last Page are as follows:

    //Get the collection length. fr-sheetbutton-container specifies the sheet collection.
    var len = $(".fr-sheetbutton-container").length;
    //Jump to the last page. (Because the subscript starts from 0, the length needs to be reduced by 1.)
    $(".fr-sheetbutton-container").eq(len-1).trigger("click");

    Effect Display

    PC

    Save the template and click Data Entry Preview or Data Analysis Preview. The following figure shows the effect.

    1.gif

    Mobile Terminal

    The effect cannot be previewed on mobile terminals.

    Template Download

    You can click to download the template Sheet Switchover by JS-based Clicking.cpt.

    Attachment List


    Theme: Parameter
    • Helpful
    • Not helpful
    • Only read

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

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

    不再提示

    9s后關閉

    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