Obtaining the Row Index of the Current Cell Being Edited by JS

  • Last update:June 30, 2025
  • Overview

    Problem

    You want to obtain the corresponding row index when you click a cell in a certain row, as shown in the following figure.

    动图1.gif

    Implementation Method

    You can set a cellselect event listener to obtain the corresponding row index of the selected cell and display the row index in a designated cell.

    iconNote:
    The effect cannot be previewed on mobile terminals.

    Example

    Template Preparation

    1. Create a template, and create a database query dataset ds1 with the SQL statement SELECT * FROM Sales.

    2. Design the template style, and add text widgets to cells A3 to F3, respectively, as shown in the following figure.

    1.png

    Event Adding

    Choose Template > Web Attribute > Data Entry Setting, select Set for This Template Separately in Following Settings, and add a Loading End event to display the row index of the selected cell in cell F1, as shown in the following figure.

    2.png

    The JS code is as follows:

    _g().on("cellselect", function(td) {
           //Set an event listener for cell selection.
           var num = _g().curLGP.getTDRow(td) - 2;
           //Get the current row index and subtract two from the index since the data starts from row three.
           _g().setCellValue("F1", null, num);
           //Assign a value to cell F1.
    })

    iconNote:
    If you want the column index of the current row that is being edited, you can use _g().curLGP.getTDCol(td).

    Effect Preview

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

    动图2.gif

    Template Download

    For details, you can download the template Obtaining the Row Index of the Current Cell Being Edited.cpt.

    Attachment List


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