JS 変更時のみ更新の制限を解除する

  • 作成者:ayuan0625
  • 編集回数:17次
  • 最終更新:FRInternational 于 2021-04-13
  • I. Overview

    1. Problem description

    After checking No modify,no update, when the front-end fills in, if the record has not been modified, the record will not be put into the database. In the case of a large amount of data query and backfilling, enabling this setting can significantly improve the submission performance of the report.

    In some cases, some fixed or regular values can be written into the database, and you can bind the database table fields with other types of data without setting cells.

    As shown in the example below, when the data is stored in the database, all the income fields need to be filled in false. At this time, the value corresponding to the income can be set to Boolean false.

    However, after the value is set to a non-cell or cell group type, the function of No modify,no update will be grayed out and unavailable, so how can we avoid such a restriction?

    1.png


    2. Solutions

    You can use setting submission conditions to cleverly avoid this restriction, mark the modified/inserted/deleted row, and then use the submission conditions to indirectly realize the No modify,no update function. This function is more versatile than the above.

    II. Operation steps

    1. Template preparation

    Open the template%FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Form\LineForm\LineForm1.cptin FineReport designer


    2. Set the text control

    Select cell L3, click Widget Settings in the property panel on the right, and select the Text Field, as shown in the figure below:

    2.png


    3. Modify field value

    Click Template> Data Entry Attribute, and change the value of the "Abort" field to false, as shown in the following figure:

    3.png


    4. Set submission conditions

    Click Set submission conditions, select the formula, the formula is L3=1, and click OK. As shown below:

    4.png


    5. Add mark

    Write JS code in the After editing event of the cell control that may involve modifying the content. For example, select cell B3, and click Widget Settings>Event>After editing in the property panel on the right to set the marker 1. As shown below:

    5.png


    Here, in order to obtain the row number of the current editing row, a parameter of row is defined, and the value is the formula =row(). For example, the current row is row 3, and the JS part then sets the cell value to 1, which is L3.

    The code is as follows:

    contentPane.curLGP.setCellValue('L'+row,null,1);
    contentPane.setCellValue('L'+row,null,1);

    Do the same setting in the After editing of other cell controls, that is, C3-K3 cells, the code and parameter definitions are the same.


    6. Add a mark when adding a new line

    You don't need to set it, because after adding a new cell, editing the cell will also call the code in chapter 2.5.


    7. Mark when deleting rows

    Open Template>Web Attributes>Data Entry settings and add a Delete before rowevent. The difference here is to get the row number, as shown in the following figure:

    6.png

    The JS code is as follows:

    var row=parseInt($(contentPane.curLGP.currentTDCell).attr('row'))+1;
    contentPane.curLGP.setCellValue('L'+row,null,1); 
    contentPane.setCellValue('L'+row,null,1);


    8. Effect view

    Note: To view specific SQL logs, you need to switch the log level setting to DEBUG mode in File>Options>Advanced.

    After saving, click to Data Entry Preview, try to modify, add, and delete respectively, you can see the effect.

    III. Template download

    Click to download the template:

    Lift the Restriction of Unmodified, Non-updated And Unavailable.cpt

    Template location : %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\DataEntry\Lift the Restriction of Unmodified, Non-updated And Unavailable.cpt

    Attachment List


    Theme: FineReport データ書き込み
    既に最初
    既に最後
    • Helpful
    • Not helpful
    • Only read