JS to refresh the current page

  • Last update:  2021-06-08
  • I.Overview

    1. Expected effect

    1) Example 1: Data entry and refresh successfully

    1.gif

    2) Example 2: Data verification refresh

    2.gif

    3) Example 3: Click button to refresh

    3.gif


    2. Realization ideas

    • Refresh the current page through location.reload(), which is the same as manual refresh.

    • If the report has multiple pages, it will return to the first page after refreshing.

    • If the report has a parameter interface, refreshing is equivalent to reloading, and the parameter query results before refreshing are not retained.

    • Support mobile terminal refresh.

    • Refresh effect can be triggered wherever JavaScript can be used.

    II. Example 1: Data entry and refresh successfully

    1. Data preparation

    Create a new general report, create a new dataset ds1, the SQL statement is: SELECT * FROM EMPLOYEE

    4.png


    2. Design report

    Design the table as shown in the figure below, see for details: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Form\First_Form.cpt

    5.png


    3. Add event

    Click Template>Web Attributes>Data Entry Settings, select individually set for the template, and add a "Data Entry Successful" event, as shown in the figure below:

    6.png

    The JavaScript code is as follows:

    location.reload();

    4. Preview effect

    Save the template, click data entry preview, and the refresh effect after the template is completed is as shown in the I.1.1).

    Note: Support mobile terminal.

    III. Example 2: Data verification refresh

    1. Data preparation

    Create a new general report, create a new dataset ds1, the SQL statement is: SELECT * FROM Product order by ProductID limit 5

    7.png


    2. Design report

    Design the table as shown in the figure below, see for details: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Form\RowForm\Simple_Row-based_Form.cpt

    8.png

    Note: A text field widget is inserted in all cells B3 ~ K3.


    3. Add event

    Click Template>Web Attributes>Data Entry Settings, select individually set for the template, and add an "After Validation" event, as shown in the figure below:

    9.png


    4. Preview effect

    Save the template, click data entry preview, the refresh effect after data verification is shown in I.1.2).

    Note: Support mobile terminal.

    IV. Example 3: Click button to refresh

    1. Data preparation

    Create a new general report, create a new dataset ds1, the SQL query statement is:

    SELECT * FROM STSCORE where 1 = 1

    ${if(len(classno)== 0 ,"","and classno ='" + classno + "'")}

    10.png

    Create a new dataset ds2, the SQL query statement is:

    SELECT * FROM STSCORE where 1=1

    ${if(len(stuno)== 0 ,"","and studentno in('" + stuno + "')")}

    11.png


    2. Design report

    1) Design the report as shown below:

    12.png

    2) Drag each field into the report, set cell B2 to expand horizontally, and customize the upper parent cell of cell A3 to A1, as shown in the following figure:

    13.png

    3) The design of the parameter pane is shown in the figure below:

    14.png


    3. Add event

    1) Add a button widget in the parameter pane and change the widget name to "Refresh", as shown in the figure below:

    15.png

    2) Add a click event to the widget, as shown in the following figure:

    16.png


    4. Preview effect

    Save the template, click data entry preview, click the refresh button, and the effect is as shown in I.1.3).

    Note: Support mobile terminal.

    V. Download templates

    1. Example 1

    Please refer to the completed template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\JS\jsApplications\Data_entry_and_refresh_successfully.cpt

    Click to download: Data_entry_and_refresh_successfully.cpt


    2. Example 2

    Please refer to the completed template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\JS\jsApplications\Data_verification_refresh.cpt

    Click to download: Data_verification_refresh.cpt


    3. Example 3

    Please refer to the completed template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\JS\jsApplications\Click_button_to_refresh.cpt

    Click to download: Click_ button_to_refresh.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