JS Confirm Before Delete Row

  • Last update:  2020-12-15
  • I. Overview

    1.1 Requirement

    When users perform row-based data entry, FineReport will provide users with the following effect, namely, when users click the [Delete Row] button, the dialog box “If you confirm to delete the row” pops up. If users click [Yes], the data will be deleted and the [Submit a Loading Event] will be executed. If users click [Cancel], no action will be executed.

     


    1.2 Solution

    Use the [Delete Row] button to add a Click Event. Execute different actions by inputting the JS code to get different return values.

    II. Sample

    2.1 Create a template

    Design a template as follows:


    2.2 Add widgets

    Choose H3, click Attribute Setting>Widget Setting on the right pane to add a [Button Widget] and set the Button Type as [Delete Row]. Set the [Specify Cell] as A3, as shown below:

     


    2.3 Add a click event

    Choose H3. Click Attribute Setting>Widget Setting>Event on the right pane to add a Click Event, as shown below:

     

    Input the JS code:

    if(confirm("Are you sure to delete?"))   //The dialog box “If you confirm to delete the row” pops up.
    {
      setTimeout(function() {
         _g('${sessionID}').writeReport();   //Execute [Submit a Loading Event] action.
      }, 2000);
      return true;    //If users click [Yes], the return value is true, and above actions will be executed.
    }else{
       return false; //If users click [Cancel], the return value is false, and above actions will not be executed.
    }

    2.4 Preview

    Save the template and click [Data Entry Preview]. The preview effect on a PC is shown as below:

     

    Note

    The default action of [Delete Row] is deleting the selected row in the page and then executing [Submit a Loading Event]. As a result, when the data are deleted, there is a two-second delay before the execution of [Submit a Loading Event].

    III. Download the template

    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