Inserting a Custom Number of Rows by JS

  • Last update:July 08, 2025
  • Overview

    Expected Effect

    During report development, you often want to customize the number of rows to be added, rather than adding one row at a time with one click.

    The following figure shows the effect.

    Implementation Method

    You can add a JS Click event for a button widget located in a cell to realize the function of customizing the number of rows by the appendReportRow() function. For details about the API description, see Exclusive API for Data Entry Preview.

    Example

    Designing the Report Style

    1. Create a template, design the report style, and add text widgets for cells A3 to F3, respectively, as shown in the following figure.

    2. To work with the Insert Row button (to be added later), select cell A3 and set Expansion Direction of cell A3 to Vertical, as shown in the following figure.

    Adding a Button Widget

    Add a button widget for cell G3, set Button Type to Insert Row, set Specified Cell to A3, and modify Number of Rows to 0, as shown in the following figure.

    Adding a Click Event

    Add a Click event, which specifies the number of rows to be inserted based on the entered number, for the button widget in cell G3, as shown in the following figure.

    The JavaScript code is as follows.

    num = prompt("The number of rows to be inserted: ","");
    _g().appendReportRow(this.options.location, this.options.reportIndex,num)

    iconNote:
    The appendReportRow() function is used to insert rows after the selected row.

    Preview Effect

    PC

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

    Mobile Terminal

    The following figure shows the preview effect on the DataAnalyst app and the HTML5 terminal.

    Template Download

    For details, you can download the template Inserting a Custom Number of Rows by JS.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