JS realizes the data deleted logically

  • Last update:  2021-05-26
  • I. Overview

    1. version

    Designer version
    10.0

    2. Problem description

    Users sometimes need to achieve data backup and the data cannot be used in the business interface. How to achieve it?


    3. Solution

    Solving it by deleting logically. That is, add a column of "Status" in the table, and control the visibility or invisible of the data by changing the value of the Status column.

    Filter data to display. That is, use the value of the "Status" field to restrict whether the data is displayed. For example, the original query statement is: select * from CUSTOMER, and the query statement after the status constraint is: select * from CUSTOMER where status="1".

    II. Example

    Take the CUSTOMER table in FRDemo as an example. Since there is no "Status" field in the table, the DISTRICT field is used as the mark.

    When the value in the DISTRICT field is 1, it is normal data; when the value in the DISTRICT field is 0, it is deleted data.


    1. Data preparation

    Create a new general report, create a new dataset ds1, the SQL query statement is: select * from CUSTOMER.


    2. Design report

    Drag the data column in ds1 into the template, set the border for the table, align the text in the center, and set the color of the text in column F to red. The table style is as shown in the figure below:

    1.png


    3. Add button widget

    Add a "Button" widget to cells G2 and H2, the button names are "Delete" and "Cancel delete" respectively. The steps are shown in the figure below:

    2.png


    4. Add click event

    1) Select cell G2 and click "Widget Setting > Event" on the right to add a click event. The parameter row and parameter col are added to the click event, and the values are expressed by formulas as: row()-1 and col()-2. Enter the JavaScript code as follows:

    FR.Msg.confirm("Tip", "Are you sure to delete?", function(value) {
    if (value) {
    contentPane.setCellValue(col, row, "0");
    _g().verifyAndWriteReport();
    } else {
    contentPane.setCellValue(col, row, "1");
    _g().verifyAndWriteReport();
    }
    })

    The steps are shown in the figure below:

    3.png

    2) Select cell H2, click "Widget Setting > Event" on the right to add a click event. The parameter row and col are added to the click event, and the values are expressed by formulas: row()-1 and col()-3. Enter the JavaScript code as follows:

    var v1 = contentPane.getCellValue(0, col, row);
    FR.Msg.confirm("Tip", "Are you sure to cancel?", function(value) {
    if (value) {
    contentPane.setCellValue(col, row, "1");
    _g().verifyAndWriteReport();
    } else {
    contentPane.setCellValue(col, row, "0");
    _g().verifyAndWriteReport();
    _g().parameterCommit();
    }
    });

    As shown below:

    4.png


    5. Data entry attributes setting

    Click the "Template>Data Entry Attributes", add a "Built-in SQL", select the "CUSTOMER" table in the FRDemo database, and add two fields "CUSTOMERID" and "DISTRICT" and the corresponding cells. As shown below:

    5.png

    Note: For the setting steps of data entry attributes, please refer to Data Entry Attributes.


    6. Display setting

    Select cell F2, click "Cell Attributes > Display", select "Formula Form", enter the formula: if($$$="1", "Normal", "Deleted"), which means if the current cell value is 1. It is displayed as "Normal", otherwise it is displayed as "Deleted".

    6.png


    7. Preview effect

    Save the template and click "Data Entry Preview", the effect is shown in the figure below:

    7.gif

    Note: Both App and HTML5 are supported.

    III. Download template

    Please refer to the completed template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\DataEntry\DataEntryApplication\Delete_logically.cpt

    Click to download:

    Delete_logically.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