JS Display Row Count in the Toolbar

  • Last update:  2021-01-06
  • I. Overview

    1.1 Requirement

    In viewing a report, we sometimes need a function that displays the number of rows of data on the current page.

    In the Pagination Preview toolbar, there are functions such as Previous, Next and Export, but no number of rows of data on the current page. Here, the function can be achieved by adding custom buttons. The effect is shown below:

     


    1.2 Solution

    Fetch the number of rows of data on the current page and the total number of rows of data by adding cell formulas, and then display the numbers on the text of a custom button in the toolbar by adding a Loading End event

    II. Sample

    2.1 Make a template

    1) Create a new dataset.

    2) Select A3, click on the Conditional Formatting icon in the right-hand pane, add a conditional formatting, set attribute to Pagination: Paginate After Row and Type to Formula, input the formula &A3 % 10 = 0 and click Add:

     

    3) Insert the following formula into A1: COUNT({A3}), to count the number of rows of data on the current page:

     

    4) Similarly, insert the following formula into B1: COUNT(A3), to count the total number of rows of data in the report:

     

    Note

    The formula in A1 is different from the one in B1 in that it has an extra pair of braces. {A3} means fetching the value of A3 on the current page.

    5) Right-click rows 1 and 2 and click Set Repeat Title Rows:

     

    6) Right-click row 1 and click Hide:

     


    2.2 Pagination Preview

    1) Click Template>Web Attributes>Pagination Preview and double-click on the Custom Button icon to add it to the toolbar:

     

    2) Add a Loading End event, as shown below:

     

    Input the following JavaScript codes:

    var curnum = $("td[id^='A1']").html(); //Fetch the value of A1, i.e., the number of rows of data on the current page
    var rownum = $("td[id^='B1']").html(); //Fetch the value of B1, i.e., the total number of rows of data in the report
    $('#fr-btn-CustomToolBarButton').text("The current page " + curnum + " data, In total " + rownum + " data");

     

    2.3 Data Entry Settings

    To enable data entry pagination, add a custom button in Data Entry Settings and then add a Loading End event:

     

    III. Preview

    3.1 Pagination Preview

     


    3.2 Data Entry Preview

    To enable Data Entry Preview, append &__cutpage__=v to the URL.

     

     

    IV. Download the template

    Attachment List


    Theme: Report Application
    Already the First
    Already the Last
    • 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