JS Get cell value in Pagination Report

  • Last update:  2020-11-17
  • I. Overview

    1.1 Problem

    Pagination preview reports can only be used to display data. Sometimes we also need to get the values of certain cells in the report for other operations. In the example below, we have obtained the value of a cell and then modified it, as shown below:

    1.gif


    1.2 Solution

    1) Solution 1

    When accessing a cpt template, the report Servlet will parse the cpt file into the corresponding HTML, and the report content is finally converted into a table, located in the div of id=content-container.

    Since the pagination preview is only for display, we can use jQuery syntax to obtain the specified cell.

    $("tr[tridx=row number]","div.content-container").children().eq(col number)

    Note: row/col number starts from 0.

    2) Solution 2

    After the page is loaded, the main report body is a table object, and each cell corresponds to a td object, which contains the id attribute that controls the location of the cell. The format is A1-0-102, where A1 is the table cell code. You need to use the matching symbol ^= in front of the jQuery object property to get the cell td object, then you can get the specified cell, and use the text() method provided by jQuery to get and set the value of the cell. 

    $("td[id^=Cell code-")

    Note: The cell code is similar to the cell number in the template design, such as A1, D5, etc., A1 corresponds to the first row and the first column, and D5 is the fifth row and the fourth column.

    II. Example

    Open the template %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Advanced\BetweenCellOperation\Column-wise_Running_Total .cpt

    Click Template>Template Web Attributes , click Pagination Preview Settings, and add a loading end event.

    2.1 Solution 1

    1) JavaScript

    2.png

    var a = $("tr[tridx=2]","div.content-container").children().eq(0).html();
    alert("The value of row 3, column 1 is:"+a);
    $("tr[tridx=2]","div.content-container").children().eq(0).html(2020);
    alert("The value of row 3, column 1 is changed to 2020");

    Note: The rows and column numbers here are those after the cell is expanded

    2) Preview effect

    3.gif


    2.2 Solution 2

    1) JavaScript

    4.png

    var a = $("td[id^=A3-]").text();
    alert("A3 cell value is:" + a);
    $("td[id^=A3-]").text(2020);
    alert("The value of cell B3 is changed to 2020");

    Note: The cell code here is that after the cell is expanded

    2) Preview effect

    5.gif


    III. Download template

    Attachment List


    Theme: Report Application
    • 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