Custom Buttons for Row Insertion and Deletion by JS

  • Last update:May 14, 2025
  • Overview

    Expected Effect

    You can use the Insert Row and Delete Row buttons for each row. For data entry reports with large data volumes, excessive buttons may result in slow template loading.

    How to use only one Insert Row button and one Delete Row button to insert or delete the corresponding data of the row where you hover the cursor? The following figure shows the effect.

    动图1.gif

    Implementation Method

    You can add button widgets in templates, customize the buttons as the Insert Row and Delete Row buttons, and add Click events for the custom buttons to realize the effect. For details about the API description, see Exclusive API for Data Entry Preview.

    Example

    Template Preparation

    Open the built-in template LineForm1.cpt in %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Form\LineForm.

    Alternatively, download the template LineForm1.cpt.

    Open the template and design the report as shown in the following figure.

    1.png

    Button Widget Adding

    Add Button Widget for cells J1 and K1, respectively, and set Button Type to Common separately, as shown in the following figure.

    2.png

    Modify the button name in cell J1 to Insert Row, and modify the button name in cell K1 to Delete Row. The following figure shows the effect.

    3.png

    Event Adding for Buttons

    1. Add a Click event for the Insert Row button in cell J1 and enter the corresponding JavaScript code, as shown in the following figure. With the setting, you can click the button to add a row.

    4.png

    The JavaScript code is as follows:

    _g().appendReportRC(1);//Click the button to add a row.

    2. Similarly, add a Click event for the Delete Row button in cell K1. With the setting, you can click the button to delete a row. The JavaScript code is as follows:

    _g().deleteReportRC();//Click the button to delete a row.

    Effect Display

    Save the template and click Data Entry Preview. The effect is the same as that shown in section "Expected Effect."

    iconNote:
    The effect cannot be previewed on mobile terminals.

    Template Download

    For details, you can download the template Adding and Deletion.cpt.

    Attachment List


    Theme: 数据准备
    • 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