Custom Submission Button by JS

  • Last update:May 14, 2025
  • Overview

    Problem

    If you customize a button to realize some of your business logic and also want the custom button to realize data submission to the database, how to realize the submission operation by the custom button in FineReport?

    Solution

    You can add a click event for the custom button and use the JS API method provided by FineReport to perform the submission operation by clicking the button. For details about the API description, see Exclusive API for Data Entry Preview.

    Example

    Template Preparation

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

    Add a button widget in cell B1, set Button Type to Common, and set Button Name to Submit. The following figure shows the effect.

    1.png

    Click Event Setting

    Select cell B1 where the Submit button is located, and add a Click event.

    2.png

    The JavaScript code is as follows:

    _g().verifyAndWriteReport();
    //Verify and submit data.

    The code allows you to realize the same effect that is realized by clicking the submission button on the toolbar. If you need other submission effects, you can modify the API to the corresponding API.

    Effect Display

    Save the report and click Data Entry Preview. Modify a record of data and click the Submit button. After the Success prompt is displayed, you can preview the entered data in Database Query. The following figure shows the effect.

    3.png

    You can preview the template on mobile terminals. The following figure shows the effect.

    最后一张.jpg

    Template Download

    For details, you can download the template Custom Submission Button by JS.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